当前位置: 首页>>代码示例>>Golang>>正文


Golang Storage.StoreImage方法代码示例

本文整理汇总了Golang中github.com/tsuru/docker-cluster/cluster.Storage.StoreImage方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.StoreImage方法的具体用法?Golang Storage.StoreImage怎么用?Golang Storage.StoreImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tsuru/docker-cluster/cluster.Storage的用法示例。


在下文中一共展示了Storage.StoreImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: testStorageStoreRemoveImage

func testStorageStoreRemoveImage(storage cluster.Storage, t *testing.T) {
	err := storage.StoreImage("img-1", "host-1")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "host-2")
	assertIsNil(err, t)
	err = storage.RemoveImage("img-1")
	assertIsNil(err, t)
	_, err = storage.RetrieveImage("img-1")
	if err != cstorage.ErrNoSuchImage {
		t.Errorf("Error should be cstorage.ErrNoSuchImage, received: %s", err)
	}
}
开发者ID:wdxxs2z,项目名称:docker-cluster,代码行数:12,代码来源:storage.go

示例2: testRetrieveImages

func testRetrieveImages(storage cluster.Storage, t *testing.T) {
	defer storage.RemoveImage("img-1", "id1", "host-1.something")
	defer storage.RemoveImage("img-1", "id1", "host-2")
	defer storage.RemoveImage("img-1", "id2", "host-2")
	err := storage.StoreImage("img-1", "id1", "host-1.something")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "id1", "host-2")
	assertIsNil(err, t)
	imgs, err := storage.RetrieveImages()
	assertIsNil(err, t)
	if len(imgs) != 2 {
		t.Errorf("Unexpected len %d - expected %d", len(imgs), 2)
	}
}
开发者ID:roberto,项目名称:docker-cluster,代码行数:14,代码来源:storage.go

示例3: testStorageStoreImageIgnoreDups

func testStorageStoreImageIgnoreDups(storage cluster.Storage, t *testing.T) {
	defer storage.RemoveImage("img-x", "id1", "host-1")
	err := storage.StoreImage("img-x", "id1", "host-1")
	assertIsNil(err, t)
	err = storage.StoreImage("img-x", "id1", "host-1")
	assertIsNil(err, t)
	img, err := storage.RetrieveImage("img-x")
	assertIsNil(err, t)
	expected := cluster.Image{Repository: "img-x", LastId: "id1", LastNode: "host-1", History: []cluster.ImageHistory{{
		Node:    "host-1",
		ImageId: "id1",
	}}}
	compareImage(img, expected, t)
}
开发者ID:roberto,项目名称:docker-cluster,代码行数:14,代码来源:storage.go

示例4: testStorageStoreImageIgnoreDups

func testStorageStoreImageIgnoreDups(storage cluster.Storage, t *testing.T) {
	defer storage.RemoveImage("img-x")
	err := storage.StoreImage("img-x", "host-1")
	assertIsNil(err, t)
	err = storage.StoreImage("img-x", "host-1")
	assertIsNil(err, t)
	hosts, err := storage.RetrieveImage("img-x")
	assertIsNil(err, t)
	if len(hosts) != 1 {
		t.Fatalf("Expected host list to have len 1, got: %d", len(hosts))
	}
	if hosts[0] != "host-1" {
		t.Fatalf("Expected host list to have value host-1, got: %s", hosts[0])
	}
}
开发者ID:wdxxs2z,项目名称:docker-cluster,代码行数:15,代码来源:storage.go

示例5: testStorageStoreRetrieveImage

func testStorageStoreRetrieveImage(storage cluster.Storage, t *testing.T) {
	defer storage.RemoveImage("img-1", "id1", "host-1.something")
	defer storage.RemoveImage("img-1", "id1", "host-2")
	defer storage.RemoveImage("img-1", "id2", "host-2")
	err := storage.StoreImage("img-1", "id1", "host-1.something")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "id1", "host-2")
	assertIsNil(err, t)
	img, err := storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	expected := cluster.Image{Repository: "img-1", LastId: "id1", LastNode: "host-2", History: []cluster.ImageHistory{{
		Node:    "host-1.something",
		ImageId: "id1",
	}, {
		Node:    "host-2",
		ImageId: "id1",
	}}}
	compareImage(img, expected, t)
	err = storage.StoreImage("img-1", "id2", "host-2")
	assertIsNil(err, t)
	expected.History = append(expected.History, cluster.ImageHistory{Node: "host-2", ImageId: "id2"})
	expected.LastId = "id2"
	img, err = storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	compareImage(img, expected, t)
}
开发者ID:roberto,项目名称:docker-cluster,代码行数:26,代码来源:storage.go

示例6: testStorageStoreRetrieveImage

func testStorageStoreRetrieveImage(storage cluster.Storage, t *testing.T) {
	defer storage.RemoveImage("img-1")
	defer storage.RemoveImage("img-2")
	err := storage.StoreImage("img-1", "host-1")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "host-2")
	assertIsNil(err, t)
	err = storage.StoreImage("img-2", "host-2")
	assertIsNil(err, t)
	hosts, err := storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	sort.Strings(hosts)
	if !reflect.DeepEqual(hosts, []string{"host-1", "host-2"}) {
		t.Errorf("unexpected array %#v", hosts)
	}
}
开发者ID:wdxxs2z,项目名称:docker-cluster,代码行数:16,代码来源:storage.go

示例7: testStorageStoreRemoveImage

func testStorageStoreRemoveImage(storage cluster.Storage, t *testing.T) {
	err := storage.StoreImage("img-1", "id1", "host-1")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "id1", "host-2")
	assertIsNil(err, t)
	err = storage.StoreImage("img-1", "id2", "host-2")
	assertIsNil(err, t)
	expected := cluster.Image{Repository: "img-1", LastId: "id2", LastNode: "host-2", History: []cluster.ImageHistory{{
		Node:    "host-1",
		ImageId: "id1",
	}, {
		Node:    "host-2",
		ImageId: "id1",
	}, {
		Node:    "host-2",
		ImageId: "id2",
	}}}
	img, err := storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	compareImage(img, expected, t)
	err = storage.RemoveImage("img-1", "id1", "host-1")
	assertIsNil(err, t)
	expected.History = []cluster.ImageHistory{{
		Node:    "host-2",
		ImageId: "id1",
	}, {
		Node:    "host-2",
		ImageId: "id2",
	}}
	img, err = storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	compareImage(img, expected, t)
	err = storage.RemoveImage("img-1", "id1", "host-2")
	assertIsNil(err, t)
	expected.History = []cluster.ImageHistory{{
		Node:    "host-2",
		ImageId: "id2",
	}}
	img, err = storage.RetrieveImage("img-1")
	assertIsNil(err, t)
	compareImage(img, expected, t)
	err = storage.RemoveImage("img-1", "id2", "host-2")
	_, err = storage.RetrieveImage("img-1")
	if err != cstorage.ErrNoSuchImage {
		t.Fatalf("Expected error to be ErrNoSuchImage, got %s", err)
	}
}
开发者ID:roberto,项目名称:docker-cluster,代码行数:47,代码来源:storage.go


注:本文中的github.com/tsuru/docker-cluster/cluster.Storage.StoreImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。