@@ -29,6 +29,7 @@ type mockService struct {
2929 wsCloseCode int
3030 statusResponseCode int
3131 imageResponseCode int
32+ cancelResponseCode int
3233 httpAddr string
3334}
3435
@@ -39,12 +40,13 @@ func TestMain(m *testing.M) {
3940}
4041
4142const (
42- authToken = "auth_token"
43- stdoutContents = "some_output"
44- imageContents = "image_contents"
45- buildPath = "/v1/build"
46- wsPath = "/v1/build-ws/"
47- imagePath = "/v1/image"
43+ authToken = "auth_token"
44+ stdoutContents = "some_output"
45+ imageContents = "image_contents"
46+ buildPath = "/v1/build"
47+ wsPath = "/v1/build-ws/"
48+ imagePath = "/v1/image"
49+ buildCancelSuffix = "/_cancel"
4850)
4951
5052func newResponse (m * mockService , id string , def []byte , libraryRef string ) client.BuildInfo {
@@ -110,6 +112,15 @@ func (m *mockService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
110112 m .t .Fatal (err )
111113 }
112114 }
115+ } else if r .Method == http .MethodPut && strings .HasSuffix (r .RequestURI , buildCancelSuffix ) {
116+ // Mock build cancellation endpoint
117+ if m .cancelResponseCode == http .StatusNoContent {
118+ w .WriteHeader (http .StatusNoContent )
119+ } else {
120+ if err := jsonresp .WriteError (w , "" , m .cancelResponseCode ); err != nil {
121+ m .t .Fatal (err )
122+ }
123+ }
113124 } else {
114125 w .WriteHeader (http .StatusNotFound )
115126 }
0 commit comments