66 "fmt"
77 "os"
88 "path/filepath"
9- "runtime"
109 "strings"
1110 "testing"
1211
@@ -59,7 +58,6 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
5958 logger logging.Logger
6059 out bytes.Buffer
6160 tmpDir string
62- target dist.Target
6361 )
6462 var prepareFetcherWithRunImages = func () {
6563 mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , gomock .Any ()).Return (fakeRunImage , nil ).AnyTimes ()
@@ -188,11 +186,6 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
188186
189187 tmpDir , err = os .MkdirTemp ("" , "create-builder-test" )
190188 h .AssertNil (t , err )
191-
192- target = dist.Target {
193- OS : runtime .GOOS ,
194- Arch : runtime .GOARCH ,
195- }
196189 })
197190
198191 it .After (func () {
@@ -225,8 +218,8 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
225218 })
226219
227220 it ("should fail when the stack ID from the builder config does not match the stack ID from the build image" , func () {
228- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (fakeBuildImage , nil )
229221 h .AssertNil (t , fakeBuildImage .SetLabel ("io.buildpacks.stack.id" , "other.stack.id" ))
222+ prepareFetcherWithBuildImage ()
230223 prepareFetcherWithRunImages ()
231224
232225 err := subject .CreateBuilder (context .TODO (), opts )
@@ -369,13 +362,13 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
369362 })
370363
371364 it ("should warn when the run image cannot be found" , func () {
372- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (fakeBuildImage , nil )
365+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (fakeBuildImage , nil )
373366
374- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
375- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
367+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
368+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
376369
377- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
378- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
370+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
371+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (nil , errors .Wrap (image .ErrNotFound , "yikes" ))
379372
380373 err := subject .CreateBuilder (context .TODO (), opts )
381374 h .AssertNil (t , err )
@@ -384,14 +377,14 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
384377 })
385378
386379 it ("should fail when not publish and the run image cannot be fetched" , func () {
387- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .New ("yikes" ))
380+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (nil , errors .New ("yikes" ))
388381
389382 err := subject .CreateBuilder (context .TODO (), opts )
390383 h .AssertError (t , err , "failed to fetch image: yikes" )
391384 })
392385
393386 it ("should fail when publish and the run image cannot be fetched" , func () {
394- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways , Target : & target }).Return (nil , errors .New ("yikes" ))
387+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false , PullPolicy : image .PullAlways }).Return (nil , errors .New ("yikes" ))
395388
396389 opts .Publish = true
397390 err := subject .CreateBuilder (context .TODO (), opts )
@@ -411,12 +404,12 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
411404 when ("publish is true" , func () {
412405 it ("should only try to validate the remote run image" , func () {
413406 mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true }).Times (0 )
414- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true , Target : & target }).Times (0 )
407+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : true }).Times (0 )
415408 mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : true }).Times (0 )
416409
417- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : false , Target : & target }).Return (fakeBuildImage , nil )
418- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false , Target : & target }).Return (fakeRunImage , nil )
419- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : false , Target : & target }).Return (fakeRunImageMirror , nil )
410+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : false }).Return (fakeBuildImage , nil )
411+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/run-image" , image.FetchOptions {Daemon : false }).Return (fakeRunImage , nil )
412+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "localhost:5000/some/run-image" , image.FetchOptions {Daemon : false }).Return (fakeRunImageMirror , nil )
420413
421414 opts .Publish = true
422415
@@ -430,7 +423,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
430423 when ("build image not found" , func () {
431424 it ("should fail" , func () {
432425 prepareFetcherWithRunImages ()
433- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (nil , image .ErrNotFound )
426+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (nil , image .ErrNotFound )
434427
435428 err := subject .CreateBuilder (context .TODO (), opts )
436429 h .AssertError (t , err , "fetch build image: not found" )
@@ -442,7 +435,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
442435 fakeImage := fakeBadImageStruct {}
443436
444437 prepareFetcherWithRunImages ()
445- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (fakeImage , nil )
438+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (fakeImage , nil )
446439
447440 err := subject .CreateBuilder (context .TODO (), opts )
448441 h .AssertError (t , err , "failed to create builder: invalid build-image" )
@@ -466,7 +459,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
466459 prepareFetcherWithRunImages ()
467460
468461 h .AssertNil (t , fakeBuildImage .SetOS ("windows" ))
469- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways , Target : & target }).Return (fakeBuildImage , nil )
462+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image.FetchOptions {Daemon : true , PullPolicy : image .PullAlways }).Return (fakeBuildImage , nil )
470463
471464 err = packClientWithExperimental .CreateBuilder (context .TODO (), opts )
472465 h .AssertNil (t , err )
@@ -478,7 +471,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
478471 prepareFetcherWithRunImages ()
479472
480473 h .AssertNil (t , fakeBuildImage .SetOS ("windows" ))
481- mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , image. FetchOptions { Daemon : true , PullPolicy : image . PullAlways , Target : & target } ).Return (fakeBuildImage , nil )
474+ mockImageFetcher .EXPECT ().Fetch (gomock .Any (), "some/build-image" , gomock . Any () ).Return (fakeBuildImage , nil )
482475
483476 err := subject .CreateBuilder (context .TODO (), opts )
484477 h .AssertError (t , err , "failed to create builder: Windows containers support is currently experimental." )
0 commit comments