@@ -16,12 +16,14 @@ type ACIMock struct {
|
||||
OnCreate func(string, string, string, *aci.ContainerGroup) (int, interface{})
|
||||
OnGetContainerGroups func(string, string) (int, interface{})
|
||||
OnGetContainerGroup func(string, string, string) (int, interface{})
|
||||
OnGetRPManifest func() (int, interface{})
|
||||
}
|
||||
|
||||
const (
|
||||
containerGroupsRoute = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ContainerInstance/containerGroups"
|
||||
containerGroupRoute = containerGroupsRoute + "/{containerGroup}"
|
||||
containerGroupLogRoute = containerGroupRoute + "/containers/{containerName}/logs"
|
||||
resourceProviderRoute = "/providers/Microsoft.ContainerInstance"
|
||||
)
|
||||
|
||||
// NewACIMock creates a new Azure Container Instance mock server.
|
||||
@@ -103,6 +105,22 @@ func (mock *ACIMock) start() {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}).Methods("GET")
|
||||
|
||||
router.HandleFunc(
|
||||
resourceProviderRoute,
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
if mock.OnGetRPManifest != nil {
|
||||
statusCode, response := mock.OnGetRPManifest()
|
||||
w.WriteHeader(statusCode)
|
||||
b := new(bytes.Buffer)
|
||||
json.NewEncoder(b).Encode(response)
|
||||
w.Write(b.Bytes())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}).Methods("GET")
|
||||
|
||||
mock.server = httptest.NewServer(router)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user