@@ -69,76 +69,36 @@ func TestModelFilterWithWildcardInMiddle(t *testing.T) {
6969}
7070
7171func TestValidateSourceFilters (t * testing.T ) {
72- t .Run ("valid source with no filters" , func (t * testing.T ) {
73- source := & Source {
74- CatalogSource : apimodels.CatalogSource {
75- Id : "test" ,
76- Name : "Test source" ,
77- },
78- }
79- err := ValidateSourceFilters (source )
72+ t .Run ("no filters" , func (t * testing.T ) {
73+ err := ValidateSourceFilters (nil , nil )
8074 assert .NoError (t , err )
8175 })
8276
83- t .Run ("valid source with patterns" , func (t * testing.T ) {
84- source := & Source {
85- CatalogSource : apimodels.CatalogSource {
86- Id : "test" ,
87- Name : "Test source" ,
88- IncludedModels : []string {"Granite/*" , "Meta/*" },
89- ExcludedModels : []string {"*-beta" },
90- },
91- }
92- err := ValidateSourceFilters (source )
77+ t .Run ("valid patterns" , func (t * testing.T ) {
78+ err := ValidateSourceFilters ([]string {"Granite/*" , "Meta/*" }, []string {"*-beta" })
9379 assert .NoError (t , err )
9480 })
9581
9682 t .Run ("conflicting patterns" , func (t * testing.T ) {
97- source := & Source {
98- CatalogSource : apimodels.CatalogSource {
99- Id : "test" ,
100- Name : "Test source" ,
101- IncludedModels : []string {"Granite/*" },
102- ExcludedModels : []string {"Granite/*" },
103- },
104- }
105- err := ValidateSourceFilters (source )
83+ err := ValidateSourceFilters ([]string {"Granite/*" }, []string {"Granite/*" })
10684 require .Error (t , err )
107- assert .Contains (t , err .Error (), "source test" )
10885 assert .Contains (t , err .Error (), "Granite/*" )
10986 })
11087
11188 t .Run ("empty pattern in includedModels" , func (t * testing.T ) {
112- source := & Source {
113- CatalogSource : apimodels.CatalogSource {
114- Id : "test" ,
115- Name : "Test source" ,
116- IncludedModels : []string {"Granite/*" , "" },
117- },
118- }
119- err := ValidateSourceFilters (source )
89+ err := ValidateSourceFilters ([]string {"Granite/*" , "" }, nil )
12090 require .Error (t , err )
121- assert .Contains (t , err .Error (), "source test" )
12291 assert .Contains (t , err .Error (), "pattern cannot be empty" )
12392 })
12493
125- t .Run ("invalid regex pattern" , func (t * testing.T ) {
126- // This shouldn't happen with our glob-to-regex conversion,
127- // but validates the error path exists
128- source := & Source {
129- CatalogSource : apimodels.CatalogSource {
130- Id : "test" ,
131- Name : "Test source" ,
132- IncludedModels : []string {"valid/*" },
133- },
134- }
135- err := ValidateSourceFilters (source )
136- assert .NoError (t , err ) // Our conversion always produces valid regex
94+ t .Run ("whitespace-only pattern" , func (t * testing.T ) {
95+ err := ValidateSourceFilters ([]string {" " }, nil )
96+ require .Error (t , err )
97+ assert .Contains (t , err .Error (), "pattern cannot be empty" )
13798 })
13899
139- t .Run ("nil source" , func (t * testing.T ) {
140- err := ValidateSourceFilters (nil )
141- require .Error (t , err )
142- assert .Contains (t , err .Error (), "source cannot be nil" )
100+ t .Run ("valid glob patterns" , func (t * testing.T ) {
101+ err := ValidateSourceFilters ([]string {"valid/*" }, nil )
102+ assert .NoError (t , err ) // Our conversion always produces valid regex
143103 })
144104}
0 commit comments