本文整理汇总了Golang中github.com/tsuru/docker-cluster/cluster.Storage.StoreContainer方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.StoreContainer方法的具体用法?Golang Storage.StoreContainer怎么用?Golang Storage.StoreContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/docker-cluster/cluster.Storage
的用法示例。
在下文中一共展示了Storage.StoreContainer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testStorageStoreRemoveContainer
func testStorageStoreRemoveContainer(storage cluster.Storage, t *testing.T) {
err := storage.StoreContainer("container-1", "host-9")
assertIsNil(err, t)
err = storage.RemoveContainer("container-1")
assertIsNil(err, t)
_, err = storage.RetrieveContainer("container-1")
if err != cstorage.ErrNoSuchContainer {
t.Errorf("Error should be cstorage.ErrNoSuchContainer, received: %s", err)
}
}
示例2: testStorageStoreRetrieveContainer
func testStorageStoreRetrieveContainer(storage cluster.Storage, t *testing.T) {
defer storage.RemoveContainer("container-1")
defer storage.RemoveContainer("container-2")
defer storage.RemoveContainer("container-3")
err := storage.StoreContainer("container-1", "host-1")
assertIsNil(err, t)
err = storage.StoreContainer("container-2", "host-1")
assertIsNil(err, t)
err = storage.StoreContainer("container-3", "host-2")
assertIsNil(err, t)
host, err := storage.RetrieveContainer("container-1")
assertIsNil(err, t)
if host != "host-1" {
t.Errorf("Unexpected hostname %s - expected %s", host, "host-1")
}
host, err = storage.RetrieveContainer("container-2")
assertIsNil(err, t)
if host != "host-1" {
t.Errorf("Unexpected hostname %s - expected %s", host, "host-1")
}
host, err = storage.RetrieveContainer("container-3")
assertIsNil(err, t)
if host != "host-2" {
t.Errorf("Unexpected hostname %s - expected %s", host, "host-2")
}
}
示例3: testRetrieveContainers
func testRetrieveContainers(storage cluster.Storage, t *testing.T) {
defer storage.RemoveContainer("container-1")
defer storage.RemoveContainer("container-2")
defer storage.RemoveContainer("container-3")
err := storage.StoreContainer("container-1", "host-1")
assertIsNil(err, t)
err = storage.StoreContainer("container-2", "host-1")
assertIsNil(err, t)
err = storage.StoreContainer("container-3", "host-2")
assertIsNil(err, t)
containers, err := storage.RetrieveContainers()
assertIsNil(err, t)
if len(containers) != 3 {
t.Errorf("Unexpected len %d - expected %d", len(containers), 3)
}
}