-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow ignoring empty kinds or names. (#90)
- Loading branch information
1 parent
d6baa62
commit 7919256
Showing
6 changed files
with
200 additions
and
2 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
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
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,62 @@ | ||
package slice | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSplit_validateFilters(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
opts Options | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "prevent using allow skipping kind while using included kinds", | ||
opts: Options{ | ||
AllowEmptyKinds: true, | ||
IncludedKinds: []string{"foo"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "prevent using allow skipping kind while using excluded kinds", | ||
opts: Options{ | ||
AllowEmptyKinds: true, | ||
ExcludedKinds: []string{"foo"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "prevent using allow skipping name while using included names", | ||
opts: Options{ | ||
AllowEmptyNames: true, | ||
IncludedNames: []string{"foo"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "prevent using allow skipping name while using excluded names", | ||
opts: Options{ | ||
AllowEmptyNames: true, | ||
ExcludedNames: []string{"foo"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "cannot specify included and excluded kinds", | ||
opts: Options{ | ||
IncludedKinds: []string{"foo"}, | ||
ExcludedKinds: []string{"bar"}, | ||
}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
s := &Split{opts: tt.opts} | ||
if err := s.validateFilters(); (err != nil) != tt.wantErr { | ||
t.Errorf("Split.validateFilters() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |