diff --git a/cmd/manager/deployments_test.go b/cmd/manager/deployments_test.go index 53dbba1c5..e73c354f0 100644 --- a/cmd/manager/deployments_test.go +++ b/cmd/manager/deployments_test.go @@ -1,6 +1,8 @@ package main import ( + "bytes" + "encoding/json" "net/http" "net/http/httptest" "net/url" @@ -28,6 +30,25 @@ func TestHealthz(t *testing.T) { // TODO: Get the body and check on the content type and the body. } +func TestCreateDeployments(t *testing.T) { + c := stubContext() + tpl := &common.Template{Name: "foo"} + s := httpHarness(c, "POST /deployments", createDeploymentHandlerFunc) + defer s.Close() + + var b bytes.Buffer + if err := json.NewEncoder(&b).Encode(tpl); err != nil { + t.Fatal(err) + } + + res, err := http.Post(s.URL+"/deployments", "application/json", &b) + if err != nil { + t.Errorf("Failed POST: %s", err) + } else if res.StatusCode != http.StatusCreated { + t.Errorf("Expected status %d, got %d", http.StatusCreated, res.StatusCode) + } +} + // httpHarness is a simple test server fixture. // Simple fixture for standing up a test server with a single route. //