• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang apiserver.IsNotFound函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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 := &registrytest.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)
	}
}
开发者ID:nvdnkpr,项目名称:kubernetes,代码行数:25,代码来源:storage_test.go


示例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)
		}
	}
}
开发者ID:kei-yamazaki,项目名称:kubernetes,代码行数:28,代码来源:servicestorage_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:25,代码来源:storage_test.go


示例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)
		}
	}
}
开发者ID:kei-yamazaki,项目名称:kubernetes,代码行数:29,代码来源:servicestorage_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:11,代码来源:memory_test.go


示例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")
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:11,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:RubanDeventhiran,项目名称:kubernetes,代码行数:11,代码来源:memory_registry_test.go


示例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)
		}
	}
}
开发者ID:RubanDeventhiran,项目名称:kubernetes,代码行数:11,代码来源:memory_registry_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:14,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:14,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:14,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:17,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:19,代码来源:memory_test.go


示例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)
		}
	}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:19,代码来源:memory_test.go



注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver.IsNotFound函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang apiserver.MakeAsync函数代码示例发布时间:2022-05-23
下一篇:
Golang apiserver.InstallSupport函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap