ifix(manager): test for create deployments

This is a first pass at using the new test stub to test HTTP services.
pull/410/head
Matt Butcher 9 years ago
parent e988ca1ac5
commit c52c6c544d

@ -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.
//

Loading…
Cancel
Save