@@ -840,6 +840,20 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) {
840840 })
841841 })
842842
843+ when ("image is invalid" , func () {
844+ it ("errors" , func () {
845+ var imageName name.Tag
846+ imageName , err := name .NewTag ("/x/y/?!z" , name .WeakValidation )
847+ h .AssertError (t , err , "repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`" )
848+ lifecycle := newTestLifecycleExec (t , true , func (options * build.LifecycleOptions ) {
849+ options .Image = imageName
850+ })
851+ fakePhaseFactory := fakes .NewFakePhaseFactory ()
852+ err = lifecycle .Create (context .Background (), false , "" , false , "test" , "test" , "test" , fakeBuildCache , fakeLaunchCache , []string {}, []string {}, fakePhaseFactory )
853+ h .AssertError (t , err , "invalid image name" )
854+ })
855+ })
856+
843857 when ("-previous-image is used" , func () {
844858 when ("previous-image is invalid" , func () {
845859 it ("errors" , func () {
@@ -852,25 +866,10 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) {
852866 })
853867 fakePhaseFactory := fakes .NewFakePhaseFactory ()
854868 err = lifecycle .Create (context .Background (), false , "" , false , "test" , "test" , "test" , fakeBuildCache , fakeLaunchCache , []string {}, []string {}, fakePhaseFactory )
855- h .AssertError (t , err , fmt . Sprintf ( "%s" , err ) )
869+ h .AssertError (t , err , "invalid previous image name" )
856870 })
857871 })
858872
859- // when("image is invalid", func() {
860- // it("errors", func() {
861- // var imageName name.Tag
862- // imageName, err := name.NewTag("/x/y/z", name.WeakValidation)
863- // h.AssertNil(t, err)
864- // lifecycle := newTestLifecycleExec(t, true, func(options *build.LifecycleOptions) {
865- // options.PreviousImage = "previous-image"
866- // options.Image = imageName
867- // })
868- // fakePhaseFactory := fakes.NewFakePhaseFactory()
869- // err = lifecycle.Create(context.Background(), false, "", false, "test", "test", "test", fakeBuildCache, fakeLaunchCache, []string{}, []string{}, fakePhaseFactory)
870- // h.AssertError(t, err, fmt.Sprintf("%s", err))
871- // })
872- // })
873-
874873 when ("--publish is false" , func () {
875874 it ("passes previous-image to creator" , func () {
876875 var imageName name.Tag
0 commit comments