Commit 92db089c authored by Matt Butcher's avatar Matt Butcher

Merge pull request #410 from technosophos/fix/create-deployment-test

ifix(manager): test for create deployments
parents e988ca1a c52c6c54
package main package main
import ( import (
"bytes"
"encoding/json"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
...@@ -28,6 +30,25 @@ func TestHealthz(t *testing.T) { ...@@ -28,6 +30,25 @@ func TestHealthz(t *testing.T) {
// TODO: Get the body and check on the content type and the body. // 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. // httpHarness is a simple test server fixture.
// Simple fixture for standing up a test server with a single route. // Simple fixture for standing up a test server with a single route.
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment