本文整理汇总了Golang中github.com/docker/machine/libmachine/hosttest.GetDefaultTestHost函数的典型用法代码示例。如果您正苦于以下问题:Golang GetDefaultTestHost函数的具体用法?Golang GetDefaultTestHost怎么用?Golang GetDefaultTestHost使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetDefaultTestHost函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestStoreRemove
func TestStoreRemove(t *testing.T) {
defer cleanup()
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
path := filepath.Join(store.GetMachinesDir(), h.Name)
if _, err := os.Stat(path); os.IsNotExist(err) {
t.Fatalf("Host path doesn't exist: %s", path)
}
err = store.Remove(h.Name)
if err != nil {
t.Fatal(err)
}
if _, err := os.Stat(path); err == nil {
t.Fatalf("Host path still exists after remove: %s", path)
}
}
开发者ID:rowancarr,项目名称:machine,代码行数:28,代码来源:filestore_test.go
示例2: TestStoreSave
func TestStoreSave(t *testing.T) {
defer cleanup()
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
path := filepath.Join(store.GetMachinesDir(), h.Name)
if _, err := os.Stat(path); os.IsNotExist(err) {
t.Fatalf("Host path doesn't exist: %s", path)
}
files, _ := ioutil.ReadDir(path)
for _, f := range files {
r, err := regexp.Compile("config.json.tmp*")
if err != nil {
t.Fatalf("Failed to compile regexp string")
}
if r.MatchString(f.Name()) {
t.Fatalf("Failed to remove temp filestore:%s", f.Name())
}
}
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:30,代码来源:filestore_test.go
示例3: TestPrintIPEmptyGivenLocalEngine
func TestPrintIPEmptyGivenLocalEngine(t *testing.T) {
stdoutGetter := commandstest.NewStdoutGetter()
defer stdoutGetter.Stop()
host, _ := hosttest.GetDefaultTestHost()
err := printIP(host)()
assert.NoError(t, err)
assert.Equal(t, "\n", stdoutGetter.Output())
}
开发者ID:gitroctiv,项目名称:machine,代码行数:10,代码来源:commands_test.go
示例4: TestPrintIPEmptyGivenLocalEngine
func TestPrintIPEmptyGivenLocalEngine(t *testing.T) {
defer persisttest.Cleanup()
host, _ := hosttest.GetDefaultTestHost()
out, w := captureStdout()
assert.Nil(t, printIP(host)())
w.Close()
assert.Equal(t, "", strings.TrimSpace(<-out))
}
开发者ID:rominirani,项目名称:machine,代码行数:11,代码来源:commands_test.go
示例5: TestPrintIPPrintsGivenRemoteEngine
func TestPrintIPPrintsGivenRemoteEngine(t *testing.T) {
defer cleanup()
host, _ := hosttest.GetDefaultTestHost()
host.Driver = &fakedriver.FakeDriver{}
out, w := captureStdout()
assert.Nil(t, printIP(host)())
w.Close()
assert.Equal(t, "1.2.3.4", strings.TrimSpace(<-out))
}
开发者ID:rominirani,项目名称:machine,代码行数:13,代码来源:commands_test.go
示例6: TestPrintIPPrintsGivenRemoteEngine
func TestPrintIPPrintsGivenRemoteEngine(t *testing.T) {
stdoutGetter := commandstest.NewStdoutGetter()
defer stdoutGetter.Stop()
host, _ := hosttest.GetDefaultTestHost()
host.Driver = &fakedriver.Driver{
MockState: state.Running,
MockIP: "1.2.3.4",
}
err := printIP(host)()
assert.NoError(t, err)
assert.Equal(t, "1.2.3.4\n", stdoutGetter.Output())
}
开发者ID:gitroctiv,项目名称:machine,代码行数:14,代码来源:commands_test.go
示例7: TestStoreLoad
func TestStoreLoad(t *testing.T) {
defer cleanup()
expectedURL := "unix:///foo/baz"
flags := hosttest.GetTestDriverFlags()
flags.Data["url"] = expectedURL
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := h.Driver.SetConfigFromFlags(flags); err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
h, err = store.Load(h.Name)
if err != nil {
t.Fatal(err)
}
rawDataDriver, ok := h.Driver.(*host.RawDataDriver)
if !ok {
t.Fatal("Expected driver loaded from store to be of type *host.RawDataDriver and it was not")
}
realDriver := none.NewDriver(h.Name, store.Path)
if err := json.Unmarshal(rawDataDriver.Data, &realDriver); err != nil {
t.Fatalf("Error unmarshaling rawDataDriver data into concrete 'none' driver: %s", err)
}
h.Driver = realDriver
actualURL, err := h.URL()
if err != nil {
t.Fatal(err)
}
if actualURL != expectedURL {
t.Fatalf("GetURL is not %q, got %q", expectedURL, actualURL)
}
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:49,代码来源:filestore_test.go
示例8: TestStoreExists
func TestStoreExists(t *testing.T) {
defer cleanup()
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
exists, err := store.Exists(h.Name)
if exists {
t.Fatal("Host should not exist before saving")
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
exists, err = store.Exists(h.Name)
if err != nil {
t.Fatal(err)
}
if !exists {
t.Fatal("Host should exist after saving")
}
if err := store.Remove(h.Name); err != nil {
t.Fatal(err)
}
exists, err = store.Exists(h.Name)
if err != nil {
t.Fatal(err)
}
if exists {
t.Fatal("Host should not exist after removing")
}
}
开发者ID:rowancarr,项目名称:machine,代码行数:40,代码来源:filestore_test.go
示例9: TestStoreList
func TestStoreList(t *testing.T) {
defer cleanup()
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
hosts, err := store.List()
if len(hosts) != 1 {
t.Fatalf("List returned %d items, expected 1", len(hosts))
}
if hosts[0] != h.Name {
t.Fatalf("hosts[0] name is incorrect, got: %s", hosts[0])
}
}
开发者ID:rowancarr,项目名称:machine,代码行数:23,代码来源:filestore_test.go
示例10: TestStoreSaveOmitRawDriver
func TestStoreSaveOmitRawDriver(t *testing.T) {
defer cleanup()
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
configJSONPath := filepath.Join(store.GetMachinesDir(), h.Name, "config.json")
f, err := os.Open(configJSONPath)
if err != nil {
t.Fatal(err)
}
configData, err := ioutil.ReadAll(f)
if err != nil {
t.Fatal(err)
}
fakeHost := make(map[string]interface{})
if err := json.Unmarshal(configData, &fakeHost); err != nil {
t.Fatal(err)
}
if rawDriver, ok := fakeHost["RawDriver"]; ok {
t.Fatal("Should not have gotten a value for RawDriver reading host from disk but got one: ", rawDriver)
}
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:37,代码来源:filestore_test.go
示例11: TestStoreLoad
func TestStoreLoad(t *testing.T) {
defer cleanup()
expectedURL := "unix:///foo/baz"
flags := hosttest.GetTestDriverFlags()
flags.Data["url"] = expectedURL
store := getTestStore()
h, err := hosttest.GetDefaultTestHost()
if err != nil {
t.Fatal(err)
}
if err := h.Driver.SetConfigFromFlags(flags); err != nil {
t.Fatal(err)
}
if err := store.Save(h); err != nil {
t.Fatal(err)
}
h, err = store.Load(h.Name)
if err != nil {
log.Fatal(err)
}
actualURL, err := h.GetURL()
if err != nil {
t.Fatal(err)
}
if actualURL != expectedURL {
t.Fatalf("GetURL is not %q, got %q", expectedURL, actualURL)
}
}
开发者ID:rowancarr,项目名称:machine,代码行数:36,代码来源:filestore_test.go
注:本文中的github.com/docker/machine/libmachine/hosttest.GetDefaultTestHost函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论