@@ -42,10 +42,7 @@ func newTestRunner(t *testing.T, handler http.Handler) *runner {
4242 require .NoError (t , err )
4343 return newRunner (
4444 Config {
45- OrgSlug : "test-org" ,
46- PipelineSlug : "my-pipeline" ,
4745 QueueName : "my-queue" ,
48- Branch : "main" ,
4946 SubmitTimeout : 5 * time .Second ,
5047 MaxSubmitAttempts : 3 ,
5148 SubmitBackoff : time .Millisecond ,
@@ -100,32 +97,11 @@ func emptyListHandler(t *testing.T) http.HandlerFunc {
10097// --- Interface / constructor ---
10198
10299func TestNew_ImplementsInterface (t * testing.T ) {
103- r , err := NewBuildRunner (Params {Config : Config {
104- OrgSlug : "org" ,
105- PipelineSlug : "pipeline" ,
106- Branch : "main" ,
107- }})
100+ r , err := NewBuildRunner (Params {})
108101 require .NoError (t , err )
109102 var _ buildrunner.BuildRunner = r
110103}
111104
112- func TestNew_Validation (t * testing.T ) {
113- tests := []struct {
114- name string
115- params Params
116- }{
117- {"missing org" , Params {Config : Config {PipelineSlug : "p" , Branch : "main" }}},
118- {"missing pipeline" , Params {Config : Config {OrgSlug : "org" , Branch : "main" }}},
119- {"missing branch" , Params {Config : Config {OrgSlug : "org" , PipelineSlug : "p" }}},
120- }
121- for _ , tt := range tests {
122- t .Run (tt .name , func (t * testing.T ) {
123- _ , err := NewBuildRunner (tt .params )
124- require .Error (t , err )
125- })
126- }
127- }
128-
129105// --- Trigger ---
130106
131107func TestTrigger_EnqueuesJobAndReturnsID (t * testing.T ) {
@@ -177,7 +153,6 @@ func TestTrigger_SubmitsCorrectPayloadToBuildkite(t *testing.T) {
177153
178154 var req createBuildRequest
179155 require .NoError (t , json .Unmarshal (capturedBody , & req ))
180- assert .Equal (t , "main" , req .Branch )
181156 assert .Equal (t , `["github://org/repo/pull/1/aaa111"]` , req .Env [EnvKeyBaseURIs ])
182157 assert .Equal (t , `["github://org/repo/pull/2/bbb222"]` , req .Env [EnvKeyHeadURIs ])
183158 assert .Equal (t , "my-queue" , req .Env [EnvKeyQueue ])
@@ -188,7 +163,7 @@ func TestTrigger_SubmitsCorrectPayloadToBuildkite(t *testing.T) {
188163 // After a successful submit the ref is cached, so Status uses getBuild.
189164 ref , ok := r .lookupRef (id .ID )
190165 require .True (t , ok )
191- assert .Equal (t , encodeBuildRef ("test-org" , "my-pipeline" , 42 ), ref )
166+ assert .Equal (t , encodeBuildRef (42 ), ref )
192167}
193168
194169func TestTrigger_EmptyBase_ProducesJSONArray (t * testing.T ) {
@@ -235,7 +210,7 @@ func TestTrigger_MultipleChangesFlattened(t *testing.T) {
235210
236211func TestTrigger_QueueFull_ReturnsError (t * testing.T ) {
237212 r := newRunner (
238- Config {OrgSlug : "org" , PipelineSlug : "p" , Branch : "main" },
213+ Config {},
239214 & client {httpClient : http .DefaultClient },
240215 1 , 1 ,
241216 )
@@ -267,7 +242,7 @@ func TestProcessTrigger_RetriesTransientFailureThenSucceeds(t *testing.T) {
267242 assert .Equal (t , 2 , posts , "submit should retry after a transient failure" )
268243 ref , ok := r .lookupRef (id .ID )
269244 require .True (t , ok )
270- assert .Equal (t , encodeBuildRef ("test-org" , "my-pipeline" , 7 ), ref )
245+ assert .Equal (t , encodeBuildRef (7 ), ref )
271246}
272247
273248func TestTrigger_SubmitExhaustsRetries_BuildFails (t * testing.T ) {
@@ -331,7 +306,7 @@ func TestStatus_ReturnsLiveBuildkiteState(t *testing.T) {
331306 }))
332307
333308 // Inject ref directly (simulates successful processTrigger).
334- r .storeRef ("some-id" , encodeBuildRef ("test-org" , "my-pipeline" , 7 ))
309+ r .storeRef ("some-id" , encodeBuildRef (7 ))
335310
336311 status , meta , err := r .Status (context .Background (), entity.BuildID {ID : "some-id" })
337312 require .NoError (t , err )
@@ -360,14 +335,14 @@ func TestStatus_RecoversRefAfterCacheMiss(t *testing.T) {
360335 // The recovered ref is now cached for subsequent calls.
361336 ref , ok := r .lookupRef ("bk-lost" )
362337 require .True (t , ok )
363- assert .Equal (t , encodeBuildRef ("test-org" , "my-pipeline" , 7 ), ref )
338+ assert .Equal (t , encodeBuildRef (7 ), ref )
364339}
365340
366341func TestStatus_BuildkiteNotFound (t * testing.T ) {
367342 r := newTestRunner (t , http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
368343 w .WriteHeader (http .StatusNotFound )
369344 }))
370- r .storeRef ("some-id" , encodeBuildRef ("test-org" , "my-pipeline" , 99 ))
345+ r .storeRef ("some-id" , encodeBuildRef (99 ))
371346
372347 _ , _ , err := r .Status (context .Background (), entity.BuildID {ID : "some-id" })
373348 require .Error (t , err )
@@ -391,7 +366,7 @@ func TestCancel_CallsBuildkiteWhenRefKnown(t *testing.T) {
391366 w .WriteHeader (http .StatusOK )
392367 _ , _ = w .Write (buildJSON (5 , "canceled" , "" ))
393368 }))
394- r .storeRef ("some-id" , encodeBuildRef ("test-org" , "my-pipeline" , 5 ))
369+ r .storeRef ("some-id" , encodeBuildRef (5 ))
395370
396371 require .NoError (t , r .Cancel (context .Background (), entity.BuildID {ID : "some-id" }))
397372 drainCancel (t , r )
@@ -435,15 +410,15 @@ func TestCancel_AlreadyTerminal_Noop(t *testing.T) {
435410 r := newTestRunner (t , http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
436411 w .WriteHeader (http .StatusUnprocessableEntity )
437412 }))
438- r .storeRef ("some-id" , encodeBuildRef ("test-org" , "my-pipeline" , 5 ))
413+ r .storeRef ("some-id" , encodeBuildRef (5 ))
439414
440415 require .NoError (t , r .Cancel (context .Background (), entity.BuildID {ID : "some-id" }))
441416 drainCancel (t , r ) // must not panic or error
442417}
443418
444419func TestCancel_QueueFull_ReturnsError (t * testing.T ) {
445420 r := newRunner (
446- Config {OrgSlug : "org" , PipelineSlug : "p" , Branch : "main" },
421+ Config {},
447422 & client {httpClient : http .DefaultClient },
448423 1 , 1 ,
449424 )
@@ -454,29 +429,18 @@ func TestCancel_QueueFull_ReturnsError(t *testing.T) {
454429// --- Internal helpers ---
455430
456431func TestEncodeParseBuildRef_RoundTrip (t * testing.T ) {
457- tests := []struct {
458- org string
459- pipeline string
460- number int
461- }{
462- {"myorg" , "my-pipeline" , 1 },
463- {"uber" , "submit-queue-ci" , 9999 },
464- {"a" , "b" , 0 },
465- }
466- for _ , tt := range tests {
467- ref := encodeBuildRef (tt .org , tt .pipeline , tt .number )
468- org , pipeline , number , err := parseBuildRef (ref )
432+ for _ , n := range []int {1 , 9999 , 0 } {
433+ ref := encodeBuildRef (n )
434+ got , err := parseBuildRef (ref )
469435 require .NoError (t , err )
470- assert .Equal (t , tt .org , org )
471- assert .Equal (t , tt .pipeline , pipeline )
472- assert .Equal (t , tt .number , number )
436+ assert .Equal (t , n , got )
473437 }
474438}
475439
476440func TestParseBuildRef_Invalid (t * testing.T ) {
477- for _ , ref := range []string {"" , "noslash " , "only/one" , " org/pipeline/notanumber " } {
441+ for _ , ref := range []string {"" , "notanumber " , "org/pipeline/1 " } {
478442 t .Run (ref , func (t * testing.T ) {
479- _ , _ , _ , err := parseBuildRef (ref )
443+ _ , err := parseBuildRef (ref )
480444 require .Error (t , err )
481445 })
482446 }
0 commit comments