-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nil check for config output (#390)
- Loading branch information
1 parent
294862e
commit 55446da
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package config_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/snyk/vervet/v8/config" | ||
) | ||
|
||
func TestOutput_ResolvePaths(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
subject *config.Output | ||
want []string | ||
}{ | ||
{ | ||
name: "nil", | ||
subject: nil, | ||
want: []string{}, | ||
}, | ||
{ | ||
name: "returns path if exists", | ||
subject: &config.Output{ | ||
Path: "path", | ||
Paths: []string{"path1", "path2"}, | ||
}, | ||
want: []string{"path"}, | ||
}, | ||
{ | ||
name: "return paths if path is empty", | ||
subject: &config.Output{ | ||
Path: "", | ||
Paths: []string{"path1", "path2"}, | ||
}, | ||
want: []string{"path1", "path2"}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.subject.ResolvePaths(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("ResolvePaths() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters