make testclient more precise

This commit is contained in:
deads2k
2015-08-03 09:21:11 -04:00
parent 4271f28548
commit 182885e897
33 changed files with 1004 additions and 401 deletions

View File

@@ -51,9 +51,13 @@ func TestReplicationControllerStop(t *testing.T) {
if len(actions) != 7 {
t.Errorf("unexpected actions: %v, expected 6 actions (get, list, get, update, get, get, delete)", fake.Actions)
}
for i, action := range []string{"get", "list", "get", "update", "get", "get", "delete"} {
if actions[i].Action != action+"-replicationController" {
t.Errorf("unexpected action: %+v, expected %s-replicationController", actions[i], action)
for i, verb := range []string{"get", "list", "get", "update", "get", "get", "delete"} {
if actions[i].GetResource() != "replicationcontrollers" {
t.Errorf("unexpected action: %+v, expected %s-replicationController", actions[i], verb)
continue
}
if actions[i].GetVerb() != verb {
t.Errorf("unexpected action: %+v, expected %s-replicationController", actions[i], verb)
}
}
}
@@ -99,7 +103,7 @@ func TestSimpleStop(t *testing.T) {
tests := []struct {
fake *reaperFake
kind string
actions []string
actions []testclient.Action
expectError bool
test string
}{
@@ -107,8 +111,11 @@ func TestSimpleStop(t *testing.T) {
fake: &reaperFake{
Fake: &testclient.Fake{},
},
kind: "Pod",
actions: []string{"get-pod", "delete-pod"},
kind: "Pod",
actions: []testclient.Action{
testclient.NewGetAction("pods", api.NamespaceDefault, "foo"),
testclient.NewDeleteAction("pods", api.NamespaceDefault, "foo"),
},
expectError: false,
test: "stop pod succeeds",
},
@@ -116,8 +123,11 @@ func TestSimpleStop(t *testing.T) {
fake: &reaperFake{
Fake: &testclient.Fake{},
},
kind: "Service",
actions: []string{"get-service", "delete-service"},
kind: "Service",
actions: []testclient.Action{
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
testclient.NewDeleteAction("services", api.NamespaceDefault, "foo"),
},
expectError: false,
test: "stop service succeeds",
},
@@ -127,7 +137,7 @@ func TestSimpleStop(t *testing.T) {
noSuchPod: true,
},
kind: "Pod",
actions: []string{},
actions: []testclient.Action{},
expectError: true,
test: "stop pod fails, no pod",
},
@@ -136,8 +146,10 @@ func TestSimpleStop(t *testing.T) {
Fake: &testclient.Fake{},
noDeleteService: true,
},
kind: "Service",
actions: []string{"get-service"},
kind: "Service",
actions: []testclient.Action{
testclient.NewGetAction("services", api.NamespaceDefault, "foo"),
},
expectError: true,
test: "stop service fails, can't delete",
},
@@ -166,8 +178,8 @@ func TestSimpleStop(t *testing.T) {
}
for i, action := range actions {
testAction := test.actions[i]
if action.Action != testAction {
t.Errorf("unexpected action: %v; expected %v (%s)", action, testAction, test.test)
if action != testAction {
t.Errorf("unexpected action: %#v; expected %v (%s)", action, testAction, test.test)
}
}
}