[Azure] Fix the Resource.Requests/Limits Parsing Issue (#183)

* Fix the Resource.Requests/Limits Parsing Issue

* Do not run test in docker build
This commit is contained in:
Robbie Zhang
2018-04-30 17:21:15 -07:00
committed by GitHub
parent 2ffd18df9f
commit f6835d9e89
4 changed files with 227 additions and 9 deletions

View File

@@ -12,8 +12,10 @@ import (
// ACIMock implements a Azure Container Instance mock server.
type ACIMock struct {
server *httptest.Server
OnCreate func(string, string, string, *aci.ContainerGroup) (int, interface{})
server *httptest.Server
OnCreate func(string, string, string, *aci.ContainerGroup) (int, interface{})
OnGetContainerGroups func(string, string) (int, interface{})
OnGetContainerGroup func(string, string, string) (int, interface{})
}
const (
@@ -62,6 +64,45 @@ func (mock *ACIMock) start() {
w.WriteHeader(http.StatusNotImplemented)
}).Methods("PUT")
router.HandleFunc(
containerGroupRoute,
func(w http.ResponseWriter, r *http.Request) {
subscription, _ := mux.Vars(r)["subscriptionId"]
resourceGroup, _ := mux.Vars(r)["resourceGroup"]
containerGroup, _ := mux.Vars(r)["containerGroup"]
if mock.OnGetContainerGroup != nil {
statusCode, response := mock.OnGetContainerGroup(subscription, resourceGroup, containerGroup)
w.WriteHeader(statusCode)
b := new(bytes.Buffer)
json.NewEncoder(b).Encode(response)
w.Write(b.Bytes())
return
}
w.WriteHeader(http.StatusNotImplemented)
}).Methods("GET")
router.HandleFunc(
containerGroupsRoute,
func(w http.ResponseWriter, r *http.Request) {
subscription, _ := mux.Vars(r)["subscriptionId"]
resourceGroup, _ := mux.Vars(r)["resourceGroup"]
if mock.OnGetContainerGroups != nil {
statusCode, response := mock.OnGetContainerGroups(subscription, resourceGroup)
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)
}