本文整理匯總了Golang中bosh/platform/fakes.FakePlatform.GetDefaultNetworkNetwork方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePlatform.GetDefaultNetworkNetwork方法的具體用法?Golang FakePlatform.GetDefaultNetworkNetwork怎麽用?Golang FakePlatform.GetDefaultNetworkNetwork使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/platform/fakes.FakePlatform
的用法示例。
在下文中一共展示了FakePlatform.GetDefaultNetworkNetwork方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
NetworkSpecs: map[string]NetworkSpec{
"fake-net": NetworkSpec{
Fields: map[string]interface{}{"ip": "fake-net-ip"},
},
},
}))
})
})
Context("when there is one dynamic network", func() {
unresolvedSpec := V1ApplySpec{
Deployment: "fake-deployment",
NetworkSpecs: map[string]NetworkSpec{
"fake-net1": NetworkSpec{
Fields: map[string]interface{}{
"ip": "fake-net1-ip",
"netmask": "fake-net1-netmask",
"gateway": "fake-net1-gateway",
},
},
"fake-net2": NetworkSpec{
Fields: map[string]interface{}{
"type": NetworkSpecTypeDynamic,
"ip": "fake-net2-ip",
"netmask": "fake-net2-netmask",
"gateway": "fake-net2-gateway",
},
},
},
}
Context("when default network can be retrieved", func() {
BeforeEach(func() {
platform.GetDefaultNetworkNetwork = boshsettings.Network{
IP: "fake-resolved-ip",
Netmask: "fake-resolved-netmask",
Gateway: "fake-resolved-gateway",
}
})
It("returns spec with modified dynamic network and keeping everything else the same", func() {
spec, err := service.ResolveDynamicNetworks(unresolvedSpec)
Expect(err).ToNot(HaveOccurred())
Expect(spec).To(Equal(V1ApplySpec{
Deployment: "fake-deployment",
NetworkSpecs: map[string]NetworkSpec{
"fake-net1": NetworkSpec{
Fields: map[string]interface{}{
"ip": "fake-net1-ip",
"netmask": "fake-net1-netmask",
"gateway": "fake-net1-gateway",
},
},
"fake-net2": NetworkSpec{
Fields: map[string]interface{}{
"type": NetworkSpecTypeDynamic,
"ip": "fake-resolved-ip",
"netmask": "fake-resolved-netmask",
"gateway": "fake-resolved-gateway",
},
},
},
}))
})
})
示例2: init
//.........這裏部分代碼省略.........
fs.RemoveAllError = errors.New("fs-remove-all-error")
err := service.InvalidateSettings()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fs-remove-all-error"))
})
})
Describe("GetSettings", func() {
var (
loadedSettings Settings
service Service
)
BeforeEach(func() {
loadedSettings = Settings{AgentID: "some-agent-id"}
})
JustBeforeEach(func() {
service, _ = buildService(func() (Settings, error) { return loadedSettings, nil })
err := service.LoadSettings()
Expect(err).NotTo(HaveOccurred())
})
Context("when there is are no dynamic networks", func() {
It("returns settings without modifying any networks", func() {
Expect(service.GetSettings()).To(Equal(loadedSettings))
})
It("does not try to determine default network", func() {
_ = service.GetSettings()
Expect(platform.GetDefaultNetworkCalled).To(BeFalse())
})
})
Context("when there is one dynamic network", func() {
BeforeEach(func() {
loadedSettings = Settings{
Networks: map[string]Network{
"fake-net1": Network{
IP: "fake-net1-ip",
Netmask: "fake-net1-netmask",
Gateway: "fake-net1-gateway",
},
"fake-net2": Network{
Type: "dynamic",
IP: "fake-net2-ip",
Netmask: "fake-net2-netmask",
Gateway: "fake-net2-gateway",
DNS: []string{"fake-net2-dns"},
},
},
}
})
Context("when default network can be retrieved", func() {
BeforeEach(func() {
platform.GetDefaultNetworkNetwork = Network{
IP: "fake-resolved-ip",
Netmask: "fake-resolved-netmask",
Gateway: "fake-resolved-gateway",
}
})
It("returns settings with resolved dynamic network ip, netmask, gateway and keeping everything else the same", func() {
settings := service.GetSettings()
Expect(settings).To(Equal(Settings{
Networks: map[string]Network{
"fake-net1": Network{
IP: "fake-net1-ip",
Netmask: "fake-net1-netmask",
Gateway: "fake-net1-gateway",
},
"fake-net2": Network{
Type: "dynamic",
IP: "fake-resolved-ip",
Netmask: "fake-resolved-netmask",
Gateway: "fake-resolved-gateway",
DNS: []string{"fake-net2-dns"},
},
},
}))
})
})
Context("when default network fails to be retrieved", func() {
BeforeEach(func() {
platform.GetDefaultNetworkErr = errors.New("fake-get-default-network-err")
})
It("returns error", func() {
settings := service.GetSettings()
Expect(settings).To(Equal(loadedSettings))
})
})
})
})
})
}