當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeFileSystem.GlobPaths方法代碼示例

本文整理匯總了Golang中bosh/system/fakes.FakeFileSystem.GlobPaths方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.GlobPaths方法的具體用法?Golang FakeFileSystem.GlobPaths怎麽用?Golang FakeFileSystem.GlobPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bosh/system/fakes.FakeFileSystem的用法示例。


在下文中一共展示了FakeFileSystem.GlobPaths方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init


//.........這裏部分代碼省略.........
			networks := boshsettings.Networks{
				"bosh": boshsettings.Network{
					Default: []string{"dns"},
					Dns:     []string{"xx.xx.xx.xx", "yy.yy.yy.yy", "zz.zz.zz.zz"},
				},
				"vip": boshsettings.Network{
					Default: []string{},
					Dns:     []string{"aa.aa.aa.aa"},
				},
			}

			platform.SetupDhcp(networks)

			dhcpConfig := fs.GetFileTestStat("/etc/dhcp3/dhclient.conf")
			assert.NotNil(GinkgoT(), dhcpConfig)
			assert.Equal(GinkgoT(), dhcpConfig.Content, UBUNTU_EXPECTED_DHCP_CONFIG)

			assert.Equal(GinkgoT(), len(cmdRunner.RunCommands), 0)
		})

		It("ubuntu setup manual networking", func() {
			networks := boshsettings.Networks{
				"bosh": boshsettings.Network{
					Default: []string{"dns", "gateway"},
					Ip:      "192.168.195.6",
					Netmask: "255.255.255.0",
					Gateway: "192.168.195.1",
					Mac:     "22:00:0a:1f:ac:2a",
					Dns:     []string{"10.80.130.2", "10.80.130.1"},
				},
			}
			fs.WriteToFile("/sys/class/net/eth0", "")
			fs.WriteToFile("/sys/class/net/eth0/address", "22:00:0a:1f:ac:2a\n")
			fs.GlobPaths = []string{"/sys/class/net/eth0"}

			platform.SetupManualNetworking(networks)

			networkConfig := fs.GetFileTestStat("/etc/network/interfaces")
			assert.NotNil(GinkgoT(), networkConfig)
			assert.Equal(GinkgoT(), networkConfig.Content, UBUNTU_EXPECTED_NETWORK_INTERFACES)

			resolvConf := fs.GetFileTestStat("/etc/resolv.conf")
			assert.NotNil(GinkgoT(), resolvConf)
			assert.Equal(GinkgoT(), resolvConf.Content, UBUNTU_EXPECTED_RESOLV_CONF)

			time.Sleep(100 * time.Millisecond)

			assert.Equal(GinkgoT(), len(cmdRunner.RunCommands), 8)
			assert.Equal(GinkgoT(), cmdRunner.RunCommands[0], []string{"service", "network-interface", "stop", "INTERFACE=eth0"})
			assert.Equal(GinkgoT(), cmdRunner.RunCommands[1], []string{"service", "network-interface", "start", "INTERFACE=eth0"})
			assert.Equal(GinkgoT(), cmdRunner.RunCommands[2], []string{"arping", "-c", "1", "-U", "-I", "eth0", "192.168.195.6"})
			assert.Equal(GinkgoT(), cmdRunner.RunCommands[7], []string{"arping", "-c", "1", "-U", "-I", "eth0", "192.168.195.6"})
		})

		It("ubuntu setup logrotate", func() {
			platform.SetupLogrotate("fake-group-name", "fake-base-path", "fake-size")

			logrotateFileContent, err := fs.ReadFile("/etc/logrotate.d/fake-group-name")
			assert.NoError(GinkgoT(), err)
			assert.Equal(GinkgoT(), UBUNTU_EXPECTED_ETC_LOGROTATE, logrotateFileContent)
		})

		It("ubuntu set time with ntp servers", func() {
			platform.SetTimeWithNtpServers([]string{"0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"})

			ntpConfig := fs.GetFileTestStat("/fake-dir/bosh/etc/ntpserver")
開發者ID:nkuacac,項目名稱:bosh,代碼行數:67,代碼來源:ubuntu_test.go


注:本文中的bosh/system/fakes.FakeFileSystem.GlobPaths方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。