@@ -130,7 +130,7 @@ func TestLookup_NominalWithFilters(t *testing.T) {
130130 assert .ErrorContains (t , err , `resource with key "bar" not found` )
131131}
132132
133- func TestLookupByPrefix_NoMatches (t * testing.T ) {
133+ func TestLookupBySubstring_NoMatches (t * testing.T ) {
134134 b := & bundle.Bundle {
135135 Config : config.Root {
136136 Resources : config.Resources {
@@ -142,11 +142,11 @@ func TestLookupByPrefix_NoMatches(t *testing.T) {
142142 },
143143 }
144144
145- matches := LookupByPrefix (b , "qux" )
145+ matches := LookupBySubstring (b , "qux" )
146146 assert .Empty (t , matches )
147147}
148148
149- func TestLookupByPrefix_SingleMatch (t * testing.T ) {
149+ func TestLookupBySubstring_SingleMatch (t * testing.T ) {
150150 b := & bundle.Bundle {
151151 Config : config.Root {
152152 Resources : config.Resources {
@@ -160,13 +160,13 @@ func TestLookupByPrefix_SingleMatch(t *testing.T) {
160160 },
161161 }
162162
163- matches := LookupByPrefix (b , "foo" )
163+ matches := LookupBySubstring (b , "foo" )
164164 require .Len (t , matches , 1 )
165165 assert .Equal (t , "foo_job" , matches [0 ].Key )
166166 assert .Equal (t , "Foo job" , matches [0 ].Resource .GetName ())
167167}
168168
169- func TestLookupByPrefix_MultipleMatches (t * testing.T ) {
169+ func TestLookupBySubstring_MultipleMatches (t * testing.T ) {
170170 b := & bundle.Bundle {
171171 Config : config.Root {
172172 Resources : config.Resources {
@@ -179,15 +179,15 @@ func TestLookupByPrefix_MultipleMatches(t *testing.T) {
179179 },
180180 }
181181
182- matches := LookupByPrefix (b , "my_" )
182+ matches := LookupBySubstring (b , "my_" )
183183 require .Len (t , matches , 2 )
184184
185185 keys := []string {matches [0 ].Key , matches [1 ].Key }
186186 sort .Strings (keys )
187187 assert .Equal (t , []string {"my_job_1" , "my_job_2" }, keys )
188188}
189189
190- func TestLookupByPrefix_WithFilters (t * testing.T ) {
190+ func TestLookupBySubstring_WithFilters (t * testing.T ) {
191191 b := & bundle.Bundle {
192192 Config : config.Root {
193193 Resources : config.Resources {
@@ -206,12 +206,52 @@ func TestLookupByPrefix_WithFilters(t *testing.T) {
206206 return ok
207207 }
208208
209- matches := LookupByPrefix (b , "my_" , includeJobs )
209+ matches := LookupBySubstring (b , "my_" , includeJobs )
210210 require .Len (t , matches , 1 )
211211 assert .Equal (t , "my_job" , matches [0 ].Key )
212212}
213213
214- func TestLookupByPrefix_ExactPrefixMatchesAll (t * testing.T ) {
214+ func TestLookupBySubstring_MiddleMatch (t * testing.T ) {
215+ b := & bundle.Bundle {
216+ Config : config.Root {
217+ Resources : config.Resources {
218+ Jobs : map [string ]* resources.Job {
219+ "my_foo_job" : {
220+ JobSettings : jobs.JobSettings {Name : "My Foo Job" },
221+ },
222+ "bar_job" : {},
223+ },
224+ },
225+ },
226+ }
227+
228+ matches := LookupBySubstring (b , "foo" )
229+ require .Len (t , matches , 1 )
230+ assert .Equal (t , "my_foo_job" , matches [0 ].Key )
231+ }
232+
233+ func TestLookupBySubstring_SuffixMatch (t * testing.T ) {
234+ b := & bundle.Bundle {
235+ Config : config.Root {
236+ Resources : config.Resources {
237+ Jobs : map [string ]* resources.Job {
238+ "my_foo_job" : {},
239+ "my_bar_job" : {},
240+ "pipeline" : {},
241+ },
242+ },
243+ },
244+ }
245+
246+ matches := LookupBySubstring (b , "_job" )
247+ require .Len (t , matches , 2 )
248+
249+ keys := []string {matches [0 ].Key , matches [1 ].Key }
250+ sort .Strings (keys )
251+ assert .Equal (t , []string {"my_bar_job" , "my_foo_job" }, keys )
252+ }
253+
254+ func TestLookupBySubstring_ExactMatchAndContains (t * testing.T ) {
215255 b := & bundle.Bundle {
216256 Config : config.Root {
217257 Resources : config.Resources {
@@ -225,7 +265,7 @@ func TestLookupByPrefix_ExactPrefixMatchesAll(t *testing.T) {
225265 },
226266 }
227267
228- matches := LookupByPrefix (b , "foo" )
268+ matches := LookupBySubstring (b , "foo" )
229269 require .Len (t , matches , 3 )
230270
231271 keys := make ([]string , len (matches ))
0 commit comments