Remove expectNoError from pkg/registry

This commit is contained in:
Clayton Coleman 2014-08-03 19:51:34 -04:00
parent 2282f9ce3a
commit ef1329b6c8
10 changed files with 361 additions and 98 deletions

View File

@ -44,7 +44,9 @@ func TestCachingHit(t *testing.T) {
minions: expected, minions: expected,
} }
list, err := cache.List() list, err := cache.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, expected) { if !reflect.DeepEqual(list, expected) {
t.Errorf("expected: %v, got %v", expected, list) t.Errorf("expected: %v, got %v", expected, list)
} }
@ -65,7 +67,10 @@ func TestCachingMiss(t *testing.T) {
} }
fakeClock.now = time.Unix(3, 0) fakeClock.now = time.Unix(3, 0)
list, err := cache.List() list, err := cache.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, fakeRegistry.minions) { if !reflect.DeepEqual(list, fakeRegistry.minions) {
t.Errorf("expected: %v, got %v", fakeRegistry.minions, list) t.Errorf("expected: %v, got %v", fakeRegistry.minions, list)
} }
@ -85,9 +90,15 @@ func TestCachingInsert(t *testing.T) {
minions: expected, minions: expected,
} }
err := cache.Insert("foo") err := cache.Insert("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
list, err := cache.List() list, err := cache.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, fakeRegistry.minions) { if !reflect.DeepEqual(list, fakeRegistry.minions) {
t.Errorf("expected: %v, got %v", fakeRegistry.minions, list) t.Errorf("expected: %v, got %v", fakeRegistry.minions, list)
} }
@ -107,9 +118,15 @@ func TestCachingDelete(t *testing.T) {
minions: expected, minions: expected,
} }
err := cache.Delete("m2") err := cache.Delete("m2")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
list, err := cache.List() list, err := cache.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, fakeRegistry.minions) { if !reflect.DeepEqual(list, fakeRegistry.minions) {
t.Errorf("expected: %v, got %v", fakeRegistry.minions, list) t.Errorf("expected: %v, got %v", fakeRegistry.minions, list)
} }

View File

@ -29,10 +29,15 @@ func TestCloudList(t *testing.T) {
Machines: instances, Machines: instances,
} }
registry, err := MakeCloudMinionRegistry(&fakeCloud, ".*") registry, err := MakeCloudMinionRegistry(&fakeCloud, ".*")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
list, err := registry.List() list, err := registry.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, instances) { if !reflect.DeepEqual(list, instances) {
t.Errorf("Unexpected inequality: %#v, %#v", list, instances) t.Errorf("Unexpected inequality: %#v, %#v", list, instances)
} }
@ -44,16 +49,24 @@ func TestCloudContains(t *testing.T) {
Machines: instances, Machines: instances,
} }
registry, err := MakeCloudMinionRegistry(&fakeCloud, ".*") registry, err := MakeCloudMinionRegistry(&fakeCloud, ".*")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
contains, err := registry.Contains("m1") contains, err := registry.Contains("m1")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !contains { if !contains {
t.Errorf("Unexpected !contains") t.Errorf("Unexpected !contains")
} }
contains, err = registry.Contains("m100") contains, err = registry.Contains("m100")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if contains { if contains {
t.Errorf("Unexpected contains") t.Errorf("Unexpected contains")
} }
@ -65,10 +78,15 @@ func TestCloudListRegexp(t *testing.T) {
Machines: instances, Machines: instances,
} }
registry, err := MakeCloudMinionRegistry(&fakeCloud, "m[0-9]+") registry, err := MakeCloudMinionRegistry(&fakeCloud, "m[0-9]+")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
list, err := registry.List() list, err := registry.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
expectedList := []string{"m1", "m2"} expectedList := []string{"m1", "m2"}
if !reflect.DeepEqual(list, expectedList) { if !reflect.DeepEqual(list, expectedList) {
t.Errorf("Unexpected inequality: %#v, %#v", list, expectedList) t.Errorf("Unexpected inequality: %#v, %#v", list, expectedList)

View File

@ -79,7 +79,10 @@ func TestListEmptyControllerList(t *testing.T) {
registry: &mockRegistry, registry: &mockRegistry,
} }
controllers, err := storage.List(labels.Everything()) controllers, err := storage.List(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(controllers.(api.ReplicationControllerList).Items) != 0 { if len(controllers.(api.ReplicationControllerList).Items) != 0 {
t.Errorf("Unexpected non-zero ctrl list: %#v", controllers) t.Errorf("Unexpected non-zero ctrl list: %#v", controllers)
} }
@ -105,7 +108,10 @@ func TestListControllerList(t *testing.T) {
} }
controllersObj, err := storage.List(labels.Everything()) controllersObj, err := storage.List(labels.Everything())
controllers := controllersObj.(api.ReplicationControllerList) controllers := controllersObj.(api.ReplicationControllerList)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(controllers.Items) != 2 { if len(controllers.Items) != 2 {
t.Errorf("Unexpected controller list: %#v", controllers) t.Errorf("Unexpected controller list: %#v", controllers)
} }
@ -128,9 +134,15 @@ func TestExtractControllerJson(t *testing.T) {
}, },
} }
body, err := api.Encode(&controller) body, err := api.Encode(&controller)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
controllerOut, err := storage.Extract(body) controllerOut, err := storage.Extract(body)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(controller, controllerOut) { if !reflect.DeepEqual(controller, controllerOut) {
t.Errorf("Expected %#v, found %#v", controller, controllerOut) t.Errorf("Expected %#v, found %#v", controller, controllerOut)
} }
@ -173,18 +185,35 @@ func TestControllerParsing(t *testing.T) {
} }
file, err := ioutil.TempFile("", "controller") file, err := ioutil.TempFile("", "controller")
fileName := file.Name() fileName := file.Name()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
data, err := json.Marshal(expectedController) data, err := json.Marshal(expectedController)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
_, err = file.Write(data) _, err = file.Write(data)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
err = file.Close() err = file.Close()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
data, err = ioutil.ReadFile(fileName) data, err = ioutil.ReadFile(fileName)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
var controller api.ReplicationController var controller api.ReplicationController
err = json.Unmarshal(data, &controller) err = json.Unmarshal(data, &controller)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(controller, expectedController) { if !reflect.DeepEqual(controller, expectedController) {
t.Errorf("Parsing failed: %s %#v %#v", string(data), controller, expectedController) t.Errorf("Parsing failed: %s %#v %#v", string(data), controller, expectedController)
@ -232,7 +261,9 @@ func TestCreateController(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
select { select {
case <-time.After(time.Millisecond * 100): case <-time.After(time.Millisecond * 100):

View File

@ -79,12 +79,18 @@ func TestFindPort(t *testing.T) {
}, },
} }
port, err := findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: "foo"}) port, err := findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: "foo"})
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if port != 8080 { if port != 8080 {
t.Errorf("Expected 8080, Got %d", port) t.Errorf("Expected 8080, Got %d", port)
} }
port, err = findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: "bar"}) port, err = findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: "bar"})
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if port != 8000 { if port != 8000 {
t.Errorf("Expected 8000, Got %d", port) t.Errorf("Expected 8000, Got %d", port)
} }
@ -101,12 +107,18 @@ func TestFindPort(t *testing.T) {
t.Error("unexpected non-error") t.Error("unexpected non-error")
} }
port, err = findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: ""}) port, err = findPort(&manifest, util.IntOrString{Kind: util.IntstrString, StrVal: ""})
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if port != 8080 { if port != 8080 {
t.Errorf("Expected 8080, Got %d", port) t.Errorf("Expected 8080, Got %d", port)
} }
port, err = findPort(&manifest, util.IntOrString{}) port, err = findPort(&manifest, util.IntOrString{})
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if port != 8080 { if port != 8080 {
t.Errorf("Expected 8080, Got %d", port) t.Errorf("Expected 8080, Got %d", port)
} }
@ -125,7 +137,10 @@ func TestSyncEndpointsEmpty(t *testing.T) {
endpoints := MakeEndpointController(&serviceRegistry, client) endpoints := MakeEndpointController(&serviceRegistry, client)
err := endpoints.SyncServiceEndpoints() err := endpoints.SyncServiceEndpoints()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
} }
func TestSyncEndpointsError(t *testing.T) { func TestSyncEndpointsError(t *testing.T) {
@ -171,7 +186,10 @@ func TestSyncEndpointsItems(t *testing.T) {
endpoints := MakeEndpointController(&serviceRegistry, client) endpoints := MakeEndpointController(&serviceRegistry, client)
err := endpoints.SyncServiceEndpoints() err := endpoints.SyncServiceEndpoints()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(serviceRegistry.endpoints.Endpoints) != 1 { if len(serviceRegistry.endpoints.Endpoints) != 1 {
t.Errorf("Unexpected endpoints update: %#v", serviceRegistry.endpoints) t.Errorf("Unexpected endpoints update: %#v", serviceRegistry.endpoints)
} }

View File

@ -40,7 +40,10 @@ func TestEtcdGetPod(t *testing.T) {
fakeClient.Set("/registry/hosts/machine/pods/foo", util.MakeJSONString(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/hosts/machine/pods/foo", util.MakeJSONString(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
pod, err := registry.GetPod("foo") pod, err := registry.GetPod("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if pod.ID != "foo" { if pod.ID != "foo" {
t.Errorf("Unexpected pod: %#v", pod) t.Errorf("Unexpected pod: %#v", pod)
} }
@ -85,20 +88,29 @@ func TestEtcdCreatePod(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false) resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
var pod api.Pod var pod api.Pod
err = api.DecodeInto([]byte(resp.Node.Value), &pod) err = api.DecodeInto([]byte(resp.Node.Value), &pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if pod.ID != "foo" { if pod.ID != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var manifests api.ContainerManifestList var manifests api.ContainerManifestList
resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
err = api.DecodeInto([]byte(resp.Node.Value), &manifests) err = api.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" { if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests) t.Errorf("Unexpected manifest list: %#v", manifests)
@ -188,20 +200,29 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false) resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
var pod api.Pod var pod api.Pod
err = api.DecodeInto([]byte(resp.Node.Value), &pod) err = api.DecodeInto([]byte(resp.Node.Value), &pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if pod.ID != "foo" { if pod.ID != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var manifests api.ContainerManifestList var manifests api.ContainerManifestList
resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
err = api.DecodeInto([]byte(resp.Node.Value), &manifests) err = api.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" { if len(manifests.Items) != 1 || manifests.Items[0].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests) t.Errorf("Unexpected manifest list: %#v", manifests)
@ -237,20 +258,29 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false) resp, err := fakeClient.Get("/registry/hosts/machine/pods/foo", false, false)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
var pod api.Pod var pod api.Pod
err = api.DecodeInto([]byte(resp.Node.Value), &pod) err = api.DecodeInto([]byte(resp.Node.Value), &pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if pod.ID != "foo" { if pod.ID != "foo" {
t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value)
} }
var manifests api.ContainerManifestList var manifests api.ContainerManifestList
resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
err = api.DecodeInto([]byte(resp.Node.Value), &manifests) err = api.DecodeInto([]byte(resp.Node.Value), &manifests)
if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" { if len(manifests.Items) != 2 || manifests.Items[1].ID != "foo" {
t.Errorf("Unexpected manifest list: %#v", manifests) t.Errorf("Unexpected manifest list: %#v", manifests)
@ -268,7 +298,10 @@ func TestEtcdDeletePod(t *testing.T) {
}), 0) }), 0)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
err := registry.DeletePod("foo") err := registry.DeletePod("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(fakeClient.DeletedKeys) != 1 { if len(fakeClient.DeletedKeys) != 1 {
t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys) t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys)
} else if fakeClient.DeletedKeys[0] != key { } else if fakeClient.DeletedKeys[0] != key {
@ -297,7 +330,10 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
}), 0) }), 0)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
err := registry.DeletePod("foo") err := registry.DeletePod("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(fakeClient.DeletedKeys) != 1 { if len(fakeClient.DeletedKeys) != 1 {
t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys) t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys)
} }
@ -331,7 +367,10 @@ func TestEtcdEmptyListPods(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
pods, err := registry.ListPods(labels.Everything()) pods, err := registry.ListPods(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods) != 0 { if len(pods) != 0 {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -346,7 +385,10 @@ func TestEtcdListPodsNotFound(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
pods, err := registry.ListPods(labels.Everything()) pods, err := registry.ListPods(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods) != 0 { if len(pods) != 0 {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -372,7 +414,10 @@ func TestEtcdListPods(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
pods, err := registry.ListPods(labels.Everything()) pods, err := registry.ListPods(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" { if len(pods) != 2 || pods[0].ID != "foo" || pods[1].ID != "bar" {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -391,7 +436,10 @@ func TestEtcdListControllersNotFound(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
controllers, err := registry.ListControllers() controllers, err := registry.ListControllers()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(controllers) != 0 { if len(controllers) != 0 {
t.Errorf("Unexpected controller list: %#v", controllers) t.Errorf("Unexpected controller list: %#v", controllers)
} }
@ -406,7 +454,10 @@ func TestEtcdListServicesNotFound(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
services, err := registry.ListServices() services, err := registry.ListServices()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(services.Items) != 0 { if len(services.Items) != 0 {
t.Errorf("Unexpected controller list: %#v", services) t.Errorf("Unexpected controller list: %#v", services)
} }
@ -432,7 +483,10 @@ func TestEtcdListControllers(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
controllers, err := registry.ListControllers() controllers, err := registry.ListControllers()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(controllers) != 2 || controllers[0].ID != "foo" || controllers[1].ID != "bar" { if len(controllers) != 2 || controllers[0].ID != "foo" || controllers[1].ID != "bar" {
t.Errorf("Unexpected controller list: %#v", controllers) t.Errorf("Unexpected controller list: %#v", controllers)
} }
@ -443,7 +497,10 @@ func TestEtcdGetController(t *testing.T) {
fakeClient.Set("/registry/controllers/foo", util.MakeJSONString(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/controllers/foo", util.MakeJSONString(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}), 0)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
ctrl, err := registry.GetController("foo") ctrl, err := registry.GetController("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if ctrl.ID != "foo" { if ctrl.ID != "foo" {
t.Errorf("Unexpected controller: %#v", ctrl) t.Errorf("Unexpected controller: %#v", ctrl)
} }
@ -471,7 +528,10 @@ func TestEtcdDeleteController(t *testing.T) {
fakeClient := tools.MakeFakeEtcdClient(t) fakeClient := tools.MakeFakeEtcdClient(t)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
err := registry.DeleteController("foo") err := registry.DeleteController("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(fakeClient.DeletedKeys) != 1 { if len(fakeClient.DeletedKeys) != 1 {
t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys) t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys)
} }
@ -489,14 +549,20 @@ func TestEtcdCreateController(t *testing.T) {
ID: "foo", ID: "foo",
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
resp, err := fakeClient.Get("/registry/controllers/foo", false, false) resp, err := fakeClient.Get("/registry/controllers/foo", false, false)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)
} }
var ctrl api.ReplicationController var ctrl api.ReplicationController
err = api.DecodeInto([]byte(resp.Node.Value), &ctrl) err = api.DecodeInto([]byte(resp.Node.Value), &ctrl)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if ctrl.ID != "foo" { if ctrl.ID != "foo" {
t.Errorf("Unexpected pod: %#v %s", ctrl, resp.Node.Value) t.Errorf("Unexpected pod: %#v %s", ctrl, resp.Node.Value)
} }
@ -512,7 +578,10 @@ func TestEtcdUpdateController(t *testing.T) {
Replicas: 2, Replicas: 2,
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
ctrl, err := registry.GetController("foo") ctrl, err := registry.GetController("foo")
if ctrl.DesiredState.Replicas != 2 { if ctrl.DesiredState.Replicas != 2 {
t.Errorf("Unexpected controller: %#v", ctrl) t.Errorf("Unexpected controller: %#v", ctrl)
@ -539,7 +608,10 @@ func TestEtcdListServices(t *testing.T) {
} }
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
services, err := registry.ListServices() services, err := registry.ListServices()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(services.Items) != 2 || services.Items[0].ID != "foo" || services.Items[1].ID != "bar" { if len(services.Items) != 2 || services.Items[0].ID != "foo" || services.Items[1].ID != "bar" {
t.Errorf("Unexpected pod list: %#v", services) t.Errorf("Unexpected pod list: %#v", services)
} }
@ -557,12 +629,21 @@ func TestEtcdCreateService(t *testing.T) {
err := registry.CreateService(api.Service{ err := registry.CreateService(api.Service{
JSONBase: api.JSONBase{ID: "foo"}, JSONBase: api.JSONBase{ID: "foo"},
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
resp, err := fakeClient.Get("/registry/services/specs/foo", false, false) resp, err := fakeClient.Get("/registry/services/specs/foo", false, false)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
var service api.Service var service api.Service
err = api.DecodeInto([]byte(resp.Node.Value), &service) err = api.DecodeInto([]byte(resp.Node.Value), &service)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if service.ID != "foo" { if service.ID != "foo" {
t.Errorf("Unexpected service: %#v %s", service, resp.Node.Value) t.Errorf("Unexpected service: %#v %s", service, resp.Node.Value)
} }
@ -573,7 +654,10 @@ func TestEtcdGetService(t *testing.T) {
fakeClient.Set("/registry/services/specs/foo", util.MakeJSONString(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/services/specs/foo", util.MakeJSONString(api.Service{JSONBase: api.JSONBase{ID: "foo"}}), 0)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
service, err := registry.GetService("foo") service, err := registry.GetService("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if service.ID != "foo" { if service.ID != "foo" {
t.Errorf("Unexpected pod: %#v", service) t.Errorf("Unexpected pod: %#v", service)
} }
@ -598,7 +682,10 @@ func TestEtcdDeleteService(t *testing.T) {
fakeClient := tools.MakeFakeEtcdClient(t) fakeClient := tools.MakeFakeEtcdClient(t)
registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"})
err := registry.DeleteService("foo") err := registry.DeleteService("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(fakeClient.DeletedKeys) != 2 { if len(fakeClient.DeletedKeys) != 2 {
t.Errorf("Expected 2 delete, found %#v", fakeClient.DeletedKeys) t.Errorf("Expected 2 delete, found %#v", fakeClient.DeletedKeys)
} }
@ -626,9 +713,15 @@ func TestEtcdUpdateService(t *testing.T) {
}, },
} }
err := registry.UpdateService(testService) err := registry.UpdateService(testService)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
svc, err := registry.GetService("foo") svc, err := registry.GetService("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(*svc, testService) { if !reflect.DeepEqual(*svc, testService) {
t.Errorf("Unexpected service: got %#v, wanted %#v", svc, testService) t.Errorf("Unexpected service: got %#v, wanted %#v", svc, testService)
} }
@ -642,7 +735,10 @@ func TestEtcdUpdateEndpoints(t *testing.T) {
Endpoints: []string{"baz", "bar"}, Endpoints: []string{"baz", "bar"},
} }
err := registry.UpdateEndpoints(endpoints) err := registry.UpdateEndpoints(endpoints)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
response, err := fakeClient.Get("/registry/services/endpoints/foo", false, false) response, err := fakeClient.Get("/registry/services/endpoints/foo", false, false)
if err != nil { if err != nil {
t.Fatalf("Unexpected error %v", err) t.Fatalf("Unexpected error %v", err)

View File

@ -47,21 +47,32 @@ func TestBasicDelegation(t *testing.T) {
} }
list, err := healthy.List() list, err := healthy.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, mockMinionRegistry.minions) { if !reflect.DeepEqual(list, mockMinionRegistry.minions) {
t.Errorf("Expected %v, Got %v", mockMinionRegistry.minions, list) t.Errorf("Expected %v, Got %v", mockMinionRegistry.minions, list)
} }
err = healthy.Insert("foo") err = healthy.Insert("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
ok, err := healthy.Contains("m1") ok, err := healthy.Contains("m1")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !ok { if !ok {
t.Errorf("Unexpected absence of 'm1'") t.Errorf("Unexpected absence of 'm1'")
} }
ok, err = healthy.Contains("m5") ok, err = healthy.Contains("m5")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if ok { if ok {
t.Errorf("Unexpected presence of 'm5'") t.Errorf("Unexpected presence of 'm5'")
} }
@ -91,12 +102,18 @@ func TestFiltering(t *testing.T) {
expected := []string{"m2", "m3"} expected := []string{"m2", "m3"}
list, err := healthy.List() list, err := healthy.List()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(list, expected) { if !reflect.DeepEqual(list, expected) {
t.Errorf("Expected %v, Got %v", expected, list) t.Errorf("Expected %v, Got %v", expected, list)
} }
ok, err := healthy.Contains("m1") ok, err := healthy.Contains("m1")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if ok { if ok {
t.Errorf("Unexpected presence of 'm1'") t.Errorf("Unexpected presence of 'm1'")
} }

View File

@ -42,7 +42,10 @@ func TestMakeManifestNoServices(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
container := manifest.Containers[0] container := manifest.Containers[0]
if len(container.Env) != 1 || if len(container.Env) != 1 ||
container.Env[0].Name != "SERVICE_HOST" || container.Env[0].Name != "SERVICE_HOST" ||
@ -84,7 +87,10 @@ func TestMakeManifestServices(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
container := manifest.Containers[0] container := manifest.Containers[0]
envs := []api.EnvVar{ envs := []api.EnvVar{
{ {
@ -162,7 +168,10 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
}, },
}, },
}) })
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
container := manifest.Containers[0] container := manifest.Containers[0]
envs := []api.EnvVar{ envs := []api.EnvVar{

View File

@ -27,7 +27,10 @@ import (
func TestListPodsEmpty(t *testing.T) { func TestListPodsEmpty(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
pods, err := registry.ListPods(labels.Everything()) pods, err := registry.ListPods(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods) != 0 { if len(pods) != 0 {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -37,7 +40,10 @@ func TestMemoryListPods(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
registry.CreatePod("machine", api.Pod{JSONBase: api.JSONBase{ID: "foo"}}) registry.CreatePod("machine", api.Pod{JSONBase: api.JSONBase{ID: "foo"}})
pods, err := registry.ListPods(labels.Everything()) pods, err := registry.ListPods(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods) != 1 || pods[0].ID != "foo" { if len(pods) != 1 || pods[0].ID != "foo" {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -60,7 +66,10 @@ func TestMemorySetGetPods(t *testing.T) {
expectedPod := api.Pod{JSONBase: api.JSONBase{ID: "foo"}} expectedPod := api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreatePod("machine", expectedPod) registry.CreatePod("machine", expectedPod)
pod, err := registry.GetPod("foo") pod, err := registry.GetPod("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedPod.ID != pod.ID { if expectedPod.ID != pod.ID {
t.Errorf("Unexpected pod, expected %#v, actual %#v", expectedPod, pod) t.Errorf("Unexpected pod, expected %#v, actual %#v", expectedPod, pod)
} }
@ -100,7 +109,10 @@ func TestMemorySetUpdateGetPods(t *testing.T) {
registry.CreatePod("machine", oldPod) registry.CreatePod("machine", oldPod)
registry.UpdatePod(expectedPod) registry.UpdatePod(expectedPod)
pod, err := registry.GetPod("foo") pod, err := registry.GetPod("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedPod.ID != pod.ID || pod.DesiredState.Host != expectedPod.DesiredState.Host { if expectedPod.ID != pod.ID || pod.DesiredState.Host != expectedPod.DesiredState.Host {
t.Errorf("Unexpected pod, expected %#v, actual %#v", expectedPod, pod) t.Errorf("Unexpected pod, expected %#v, actual %#v", expectedPod, pod)
} }
@ -136,7 +148,10 @@ func TestMemorySetDeleteGetPods(t *testing.T) {
func TestListControllersEmpty(t *testing.T) { func TestListControllersEmpty(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
ctls, err := registry.ListControllers() ctls, err := registry.ListControllers()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(ctls) != 0 { if len(ctls) != 0 {
t.Errorf("Unexpected controller list: %#v", ctls) t.Errorf("Unexpected controller list: %#v", ctls)
} }
@ -146,7 +161,10 @@ func TestMemoryListControllers(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
registry.CreateController(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}) registry.CreateController(api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}})
ctls, err := registry.ListControllers() ctls, err := registry.ListControllers()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(ctls) != 1 || ctls[0].ID != "foo" { if len(ctls) != 1 || ctls[0].ID != "foo" {
t.Errorf("Unexpected controller list: %#v", ctls) t.Errorf("Unexpected controller list: %#v", ctls)
} }
@ -169,7 +187,10 @@ func TestMemorySetGetControllers(t *testing.T) {
expectedController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}} expectedController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreateController(expectedController) registry.CreateController(expectedController)
ctl, err := registry.GetController("foo") ctl, err := registry.GetController("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedController.ID != ctl.ID { if expectedController.ID != ctl.ID {
t.Errorf("Unexpected controller, expected %#v, actual %#v", expectedController, ctl) t.Errorf("Unexpected controller, expected %#v, actual %#v", expectedController, ctl)
} }
@ -209,7 +230,10 @@ func TestMemorySetUpdateGetControllers(t *testing.T) {
registry.CreateController(oldController) registry.CreateController(oldController)
registry.UpdateController(expectedController) registry.UpdateController(expectedController)
ctl, err := registry.GetController("foo") ctl, err := registry.GetController("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedController.ID != ctl.ID || ctl.DesiredState.Replicas != expectedController.DesiredState.Replicas { if expectedController.ID != ctl.ID || ctl.DesiredState.Replicas != expectedController.DesiredState.Replicas {
t.Errorf("Unexpected controller, expected %#v, actual %#v", expectedController, ctl) t.Errorf("Unexpected controller, expected %#v, actual %#v", expectedController, ctl)
} }
@ -245,7 +269,10 @@ func TestMemorySetDeleteGetControllers(t *testing.T) {
func TestListServicesEmpty(t *testing.T) { func TestListServicesEmpty(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
svcs, err := registry.ListServices() svcs, err := registry.ListServices()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(svcs.Items) != 0 { if len(svcs.Items) != 0 {
t.Errorf("Unexpected service list: %#v", svcs) t.Errorf("Unexpected service list: %#v", svcs)
} }
@ -255,7 +282,10 @@ func TestMemoryListServices(t *testing.T) {
registry := MakeMemoryRegistry() registry := MakeMemoryRegistry()
registry.CreateService(api.Service{JSONBase: api.JSONBase{ID: "foo"}}) registry.CreateService(api.Service{JSONBase: api.JSONBase{ID: "foo"}})
svcs, err := registry.ListServices() svcs, err := registry.ListServices()
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(svcs.Items) != 1 || svcs.Items[0].ID != "foo" { if len(svcs.Items) != 1 || svcs.Items[0].ID != "foo" {
t.Errorf("Unexpected service list: %#v", svcs) t.Errorf("Unexpected service list: %#v", svcs)
} }
@ -278,7 +308,10 @@ func TestMemorySetGetServices(t *testing.T) {
expectedService := api.Service{JSONBase: api.JSONBase{ID: "foo"}} expectedService := api.Service{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreateService(expectedService) registry.CreateService(expectedService)
svc, err := registry.GetService("foo") svc, err := registry.GetService("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedService.ID != svc.ID { if expectedService.ID != svc.ID {
t.Errorf("Unexpected service, expected %#v, actual %#v", expectedService, svc) t.Errorf("Unexpected service, expected %#v, actual %#v", expectedService, svc)
} }
@ -314,7 +347,10 @@ func TestMemorySetUpdateGetServices(t *testing.T) {
registry.CreateService(oldService) registry.CreateService(oldService)
registry.UpdateService(expectedService) registry.UpdateService(expectedService)
svc, err := registry.GetService("foo") svc, err := registry.GetService("foo")
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if expectedService.ID != svc.ID || svc.Port != expectedService.Port { if expectedService.ID != svc.ID || svc.Port != expectedService.Port {
t.Errorf("Unexpected service, expected %#v, actual %#v", expectedService, svc) t.Errorf("Unexpected service, expected %#v, actual %#v", expectedService, svc)
} }

View File

@ -29,12 +29,6 @@ import (
"github.com/fsouza/go-dockerclient" "github.com/fsouza/go-dockerclient"
) )
func expectNoError(t *testing.T, err error) {
if err != nil {
t.Errorf("Unexpected error: %#v", err)
}
}
func expectApiStatusError(t *testing.T, ch <-chan interface{}, msg string) { func expectApiStatusError(t *testing.T, ch <-chan interface{}, msg string) {
out := <-ch out := <-ch
status, ok := out.(*api.Status) status, ok := out.(*api.Status)
@ -170,7 +164,10 @@ func TestListEmptyPodList(t *testing.T) {
registry: &mockRegistry, registry: &mockRegistry,
} }
pods, err := storage.List(labels.Everything()) pods, err := storage.List(labels.Everything())
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods.(api.PodList).Items) != 0 { if len(pods.(api.PodList).Items) != 0 {
t.Errorf("Unexpected non-zero pod list: %#v", pods) t.Errorf("Unexpected non-zero pod list: %#v", pods)
} }
@ -196,7 +193,10 @@ func TestListPodList(t *testing.T) {
} }
podsObj, err := storage.List(labels.Everything()) podsObj, err := storage.List(labels.Everything())
pods := podsObj.(api.PodList) pods := podsObj.(api.PodList)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(pods.Items) != 2 { if len(pods.Items) != 2 {
t.Errorf("Unexpected pod list: %#v", pods) t.Errorf("Unexpected pod list: %#v", pods)
} }
@ -219,9 +219,15 @@ func TestExtractJson(t *testing.T) {
}, },
} }
body, err := api.Encode(&pod) body, err := api.Encode(&pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
podOut, err := storage.Extract(body) podOut, err := storage.Extract(body)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(pod, podOut) { if !reflect.DeepEqual(pod, podOut) {
t.Errorf("Expected %#v, found %#v", pod, podOut) t.Errorf("Expected %#v, found %#v", pod, podOut)
} }
@ -238,7 +244,10 @@ func TestGetPod(t *testing.T) {
} }
obj, err := storage.Get("foo") obj, err := storage.Get("foo")
pod := obj.(*api.Pod) pod := obj.(*api.Pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(*mockRegistry.pod, *pod) { if !reflect.DeepEqual(*mockRegistry.pod, *pod) {
t.Errorf("Unexpected pod. Expected %#v, Got %#v", *mockRegistry.pod, *pod) t.Errorf("Unexpected pod. Expected %#v, Got %#v", *mockRegistry.pod, *pod)
} }
@ -257,7 +266,10 @@ func TestGetPodCloud(t *testing.T) {
} }
obj, err := storage.Get("foo") obj, err := storage.Get("foo")
pod := obj.(*api.Pod) pod := obj.(*api.Pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(*mockRegistry.pod, *pod) { if !reflect.DeepEqual(*mockRegistry.pod, *pod) {
t.Errorf("Unexpected pod. Expected %#v, Got %#v", *mockRegistry.pod, *pod) t.Errorf("Unexpected pod. Expected %#v, Got %#v", *mockRegistry.pod, *pod)
} }
@ -414,7 +426,10 @@ func TestCreatePod(t *testing.T) {
DesiredState: desiredState, DesiredState: desiredState,
} }
channel, err := storage.Create(pod) channel, err := storage.Create(pod)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
select { select {
case <-time.After(time.Millisecond * 100): case <-time.After(time.Millisecond * 100):
// Do nothing, this is expected. // Do nothing, this is expected.

View File

@ -44,7 +44,10 @@ func TestServiceRegistry(t *testing.T) {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
} }
srv, err := memory.GetService(svc.ID) srv, err := memory.GetService(svc.ID)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if srv == nil { if srv == nil {
t.Errorf("Failed to find service: %s", svc.ID) t.Errorf("Failed to find service: %s", svc.ID)
} }
@ -123,7 +126,10 @@ func TestServiceRegistryExternalService(t *testing.T) {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls) t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
} }
srv, err := memory.GetService(svc.ID) srv, err := memory.GetService(svc.ID)
expectNoError(t, err) if err != nil {
t.Errorf("unexpected error: %v", err)
}
if srv == nil { if srv == nil {
t.Errorf("Failed to find service: %s", svc.ID) t.Errorf("Failed to find service: %s", svc.ID)
} }