Skip to content

Commit

Permalink
Add additional test for non-existent config file
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Dec 20, 2022
1 parent 3347e0d commit 6182e91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func initConfig(baseSearchPath *pathlib.Path, viperObj *viper.Viper) {

currentDir := baseSearchPath

for len(currentDir.Parts()) != 1 {
for len(currentDir.Parts()) > 1 {
viperObj.AddConfigPath(currentDir.String())
currentDir = currentDir.Parent()
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/mockery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,22 @@ func Test_initConfig(t *testing.T) {
base_path: "1/2/3/4",
configPath: "1/.mockery.yaml",
},
{
name: "no config file found",
base_path: "1/2/3/4",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tmpDir := pathlib.NewPath(t.TempDir())
baseDir := tmpDir.Join(strings.Split(tt.base_path, "/")...)
require.NoError(t, baseDir.MkdirAll())
configPath := tmpDir.Join(strings.Split(tt.configPath, "/")...)
configPath.WriteFile([]byte("all: True"))

configPath := pathlib.NewPath("")
if tt.configPath != "" {
configPath = tmpDir.Join(strings.Split(tt.configPath, "/")...)
configPath.WriteFile([]byte("all: True"))
}

viperObj := viper.New()

Expand Down

0 comments on commit 6182e91

Please sign in to comment.