@@ -5,9 +5,9 @@ package image_test
55
66import (
77 "bytes"
8+ "encoding/json"
89 "testing"
910
10- "github.com/pivotal/kpack/pkg/apis/build/v1alpha1"
1111 "github.com/pivotal/kpack/pkg/client/clientset/versioned/fake"
1212 "github.com/sclevine/spec"
1313 "github.com/stretchr/testify/require"
@@ -47,10 +47,14 @@ func testImageTrigger(t *testing.T, when spec.G, it spec.S) {
4747 actions , err := testhelpers.ActionRecorderList {clientSet }.ActionsByVerb ()
4848 require .NoError (t , err )
4949
50- require .Len (t , actions .Updates , 1 )
51- build := actions .Updates [0 ].GetObject ().(* v1alpha1.Build )
52- require .Equal (t , build .Name , "build-three" )
53- require .NotEmpty (t , build .Annotations [image .BuildNeededAnnotation ])
50+ require .Len (t , actions .Patches , 1 )
51+
52+ var patch buildNeededPatch
53+ err = json .Unmarshal (actions .Patches [0 ].GetPatch (), & patch )
54+ require .NoError (t , err )
55+
56+ require .Equal (t , actions .Patches [0 ].GetName (), "build-three" )
57+ require .NotEmpty (t , patch .Metadata .Annotations .BuildNeededAnnotation )
5458 })
5559 })
5660
@@ -88,10 +92,14 @@ func testImageTrigger(t *testing.T, when spec.G, it spec.S) {
8892 actions , err := testhelpers.ActionRecorderList {clientSet }.ActionsByVerb ()
8993 require .NoError (t , err )
9094
91- require .Len (t , actions .Updates , 1 )
92- build := actions .Updates [0 ].GetObject ().(* v1alpha1.Build )
93- require .Equal (t , build .Name , "build-three" )
94- require .NotEmpty (t , build .Annotations [image .BuildNeededAnnotation ])
95+ require .Len (t , actions .Patches , 1 )
96+
97+ var patch buildNeededPatch
98+ err = json .Unmarshal (actions .Patches [0 ].GetPatch (), & patch )
99+ require .NoError (t , err )
100+
101+ require .Equal (t , actions .Patches [0 ].GetName (), "build-three" )
102+ require .NotEmpty (t , patch .Metadata .Annotations .BuildNeededAnnotation )
95103 })
96104 })
97105
@@ -111,3 +119,11 @@ func testImageTrigger(t *testing.T, when spec.G, it spec.S) {
111119 })
112120 })
113121}
122+
123+ type buildNeededPatch struct {
124+ Metadata struct {
125+ Annotations struct {
126+ BuildNeededAnnotation string `json:"image.kpack.io/additionalBuildNeeded"`
127+ } `json:"annotations"`
128+ } `json:"metadata"`
129+ }
0 commit comments