本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver.IsNotFound函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsNotFound函數的具體用法?Golang IsNotFound怎麽用?Golang IsNotFound使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsNotFound函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGetEndpointsMissingService
func TestGetEndpointsMissingService(t *testing.T) {
registry := ®istrytest.ServiceRegistry{
Err: apiserver.NewNotFoundErr("service", "foo"),
}
storage := NewStorage(registry)
// returns service not found
_, err := storage.Get("foo")
if !apiserver.IsNotFound(err) || !reflect.DeepEqual(err, apiserver.NewNotFoundErr("service", "foo")) {
t.Errorf("expected NotFound error, got %#v", err)
}
// returns empty endpoints
registry.Err = nil
registry.Service = &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
}
obj, err := storage.Get("foo")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if obj.(*api.Endpoints).Endpoints != nil {
t.Errorf("unexpected endpoints: %#v", obj)
}
}
示例2: TestServiceRegistryDelete
func TestServiceRegistryDelete(t *testing.T) {
memory := MakeMemoryRegistry()
fakeCloud := &cloudprovider.FakeCloud{}
machines := []string{"foo", "bar", "baz"}
storage := MakeServiceRegistryStorage(memory, fakeCloud, MakeMinionRegistry(machines))
svc := api.Service{
JSONBase: api.JSONBase{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
}
memory.CreateService(svc)
c, _ := storage.Delete(svc.ID)
<-c
if len(fakeCloud.Calls) != 0 {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
}
srv, err := memory.GetService(svc.ID)
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("memory.GetService(%q) failed with %v; expected failure with not found error", svc.ID, err)
} else {
t.Errorf("memory.GetService(%q) = %v; expected failure with not found error", svc.ID, srv)
}
}
}
示例3: TestServiceRegistryDeleteExternal
func TestServiceRegistryDeleteExternal(t *testing.T) {
registry := memory.NewRegistry()
fakeCloud := &cloudprovider.FakeCloud{}
machines := []string{"foo", "bar", "baz"}
storage := NewRegistryStorage(registry, fakeCloud, minion.NewRegistry(machines))
svc := api.Service{
JSONBase: api.JSONBase{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true,
}
registry.CreateService(svc)
c, _ := storage.Delete(svc.ID)
<-c
if len(fakeCloud.Calls) != 2 || fakeCloud.Calls[0] != "get-zone" || fakeCloud.Calls[1] != "delete" {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
}
srv, err := registry.GetService(svc.ID)
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetService(%q) failed with %v; expected failure with not found error", svc.ID, err)
} else {
t.Errorf("registry.GetService(%q) = %v; expected failure with not found error", svc.ID, srv)
}
}
}
示例4: TestServiceRegistryExternalServiceError
func TestServiceRegistryExternalServiceError(t *testing.T) {
memory := MakeMemoryRegistry()
fakeCloud := &cloudprovider.FakeCloud{
Err: fmt.Errorf("test error"),
}
machines := []string{"foo", "bar", "baz"}
storage := MakeServiceRegistryStorage(memory, fakeCloud, MakeMinionRegistry(machines))
svc := &api.Service{
JSONBase: api.JSONBase{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
CreateExternalLoadBalancer: true,
}
c, _ := storage.Create(svc)
<-c
if len(fakeCloud.Calls) != 1 || fakeCloud.Calls[0] != "get-zone" {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
}
srv, err := memory.GetService("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("memory.GetService(%q) failed with %v; expected failure with not found error", svc.ID, err)
} else {
t.Errorf("memory.GetService(%q) = %v; expected failure with not found error", svc.ID, srv)
}
}
}
示例5: TestMemoryGetPods
func TestMemoryGetPods(t *testing.T) {
registry := NewRegistry()
pod, err := registry.GetPod("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetPod(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetPod(%q) = %v; expected failure with not found error", "foo", pod)
}
}
}
示例6: TestMemoryDeleteService
func TestMemoryDeleteService(t *testing.T) {
registry := NewRegistry()
err := registry.DeleteService("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.DeleteService(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.DeleteService(%q) succeeded; expected failure with not found error", "foo")
}
}
}
示例7: TestMemoryGetService
func TestMemoryGetService(t *testing.T) {
registry := MakeMemoryRegistry()
svc, err := registry.GetService("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetService(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetService(%q) = %v; expected failure with not found error", "foo", svc)
}
}
}
示例8: TestMemoryGetController
func TestMemoryGetController(t *testing.T) {
registry := MakeMemoryRegistry()
ctl, err := registry.GetController("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetController(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetController(%q) = %v; expected failure with not found error", "foo", ctl)
}
}
}
示例9: TestMemorySetDeleteGetServices
func TestMemorySetDeleteGetServices(t *testing.T) {
registry := NewRegistry()
expectedService := api.Service{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreateService(expectedService)
registry.DeleteService("foo")
svc, err := registry.GetService("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetService(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetService(%q) = %v; expected failure with not found error", "foo", svc)
}
}
}
示例10: TestMemorySetDeleteGetControllers
func TestMemorySetDeleteGetControllers(t *testing.T) {
registry := NewRegistry()
expectedController := api.ReplicationController{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreateController(expectedController)
registry.DeleteController("foo")
ctl, err := registry.GetController("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetController(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetController(%q) = %v; expected failure with not found error", "foo", ctl)
}
}
}
示例11: TestMemorySetDeleteGetPods
func TestMemorySetDeleteGetPods(t *testing.T) {
registry := NewRegistry()
expectedPod := api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
registry.CreatePod("machine", expectedPod)
registry.DeletePod("foo")
pod, err := registry.GetPod("foo")
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.GetPod(%q) failed with %v; expected failure with not found error", "foo", err)
} else {
t.Errorf("registry.GetPod(%q) = %v; expected failure with not found error", "foo", pod)
}
}
}
示例12: TestMemoryUpdateService
func TestMemoryUpdateService(t *testing.T) {
registry := NewRegistry()
svc := api.Service{
JSONBase: api.JSONBase{
ID: "foo",
},
Port: 9000,
}
err := registry.UpdateService(svc)
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.UpdateService(%q) failed with %v; expected failure with not found error", svc, err)
} else {
t.Errorf("registry.UpdateService(%q) succeeded; expected failure with not found error", svc)
}
}
}
示例13: TestMemoryUpdatePods
func TestMemoryUpdatePods(t *testing.T) {
registry := NewRegistry()
pod := api.Pod{
JSONBase: api.JSONBase{
ID: "foo",
},
DesiredState: api.PodState{
Host: "foo.com",
},
}
err := registry.UpdatePod(pod)
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.UpdatePod(%q) failed with %v; expected failure with not found error", pod, err)
} else {
t.Errorf("registry.UpdatePod(%q) succeeded; expected failure with not found error", pod)
}
}
}
示例14: TestMemoryUpdateController
func TestMemoryUpdateController(t *testing.T) {
registry := NewRegistry()
ctl := api.ReplicationController{
JSONBase: api.JSONBase{
ID: "foo",
},
DesiredState: api.ReplicationControllerState{
Replicas: 2,
},
}
err := registry.UpdateController(ctl)
if !apiserver.IsNotFound(err) {
if err != nil {
t.Errorf("registry.UpdateController(%q) failed with %v; expected failure with not found error", ctl, err)
} else {
t.Errorf("registry.UpdateController(%q) succeeded; expected failure with not found error", ctl)
}
}
}