This commit is contained in:
Brendan Burns 2014-06-11 12:50:01 -07:00
parent 9010ef954c
commit 9f76f13205
2 changed files with 22 additions and 25 deletions

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
) )
func expectNoError(t *testing.T, err error) { func expectNoError(t *testing.T, err error) {
@ -20,7 +20,7 @@ func TestFakeHandlerPath(t *testing.T) {
path := "/foo/bar" path := "/foo/bar"
body := "somebody" body := "somebody"
req, err := http.NewRequest(method, server.URL + path, bytes.NewBufferString(body)); req, err := http.NewRequest(method, server.URL+path, bytes.NewBufferString(body))
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -35,7 +35,7 @@ func TestFakeHandlerPathNoBody(t *testing.T) {
method := "GET" method := "GET"
path := "/foo/bar" path := "/foo/bar"
req, err := http.NewRequest(method, server.URL + path, nil); req, err := http.NewRequest(method, server.URL+path, nil)
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -45,7 +45,7 @@ func TestFakeHandlerPathNoBody(t *testing.T) {
} }
type fakeError struct { type fakeError struct {
errors[] string errors []string
} }
func (f *fakeError) Errorf(format string, args ...interface{}) { func (f *fakeError) Errorf(format string, args ...interface{}) {
@ -59,7 +59,7 @@ func TestFakeHandlerWrongPath(t *testing.T) {
path := "/foo/bar" path := "/foo/bar"
fakeT := fakeError{} fakeT := fakeError{}
req, err := http.NewRequest(method, server.URL + "/foo/baz", nil); req, err := http.NewRequest(method, server.URL+"/foo/baz", nil)
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -78,7 +78,7 @@ func TestFakeHandlerWrongMethod(t *testing.T) {
path := "/foo/bar" path := "/foo/bar"
fakeT := fakeError{} fakeT := fakeError{}
req, err := http.NewRequest("PUT", server.URL + path, nil); req, err := http.NewRequest("PUT", server.URL+path, nil)
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -98,7 +98,7 @@ func TestFakeHandlerWrongBody(t *testing.T) {
body := "somebody" body := "somebody"
fakeT := fakeError{} fakeT := fakeError{}
req, err := http.NewRequest(method, server.URL + path, bytes.NewBufferString(body)); req, err := http.NewRequest(method, server.URL+path, bytes.NewBufferString(body))
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -119,7 +119,7 @@ func TestFakeHandlerNilBody(t *testing.T) {
body := "somebody" body := "somebody"
fakeT := fakeError{} fakeT := fakeError{}
req, err := http.NewRequest(method, server.URL + path, nil); req, err := http.NewRequest(method, server.URL+path, nil)
expectNoError(t, err) expectNoError(t, err)
client := http.Client{} client := http.Client{}
_, err = client.Do(req) _, err = client.Do(req)
@ -130,5 +130,3 @@ func TestFakeHandlerNilBody(t *testing.T) {
t.Errorf("Unexpected error set: %#v", fakeT.errors) t.Errorf("Unexpected error set: %#v", fakeT.errors)
} }
} }

View File

@ -2,14 +2,14 @@ package util
import ( import (
"encoding/json" "encoding/json"
"testing" "testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
) )
func TestMakeJSONString(t *testing.T) { func TestMakeJSONString(t *testing.T) {
pod := api.Pod{ pod := api.Pod{
JSONBase: api.JSONBase{ ID: "foo" }, JSONBase: api.JSONBase{ID: "foo"},
Labels: map[string]string{ Labels: map[string]string{
"foo": "bar", "foo": "bar",
"baz": "blah", "baz": "blah",
@ -30,7 +30,7 @@ func TestHandleCrash(t *testing.T) {
expect := 10 expect := 10
for i := 0; i < expect; i = i + 1 { for i := 0; i < expect; i = i + 1 {
defer HandleCrash() defer HandleCrash()
if i % 2 == 0 { if i%2 == 0 {
panic("Test Panic") panic("Test Panic")
} }
count = count + 1 count = count + 1
@ -39,4 +39,3 @@ func TestHandleCrash(t *testing.T) {
t.Errorf("Expected %d iterations, found %d", expect, count) t.Errorf("Expected %d iterations, found %d", expect, count)
} }
} }