本文整理汇总了Golang中github.com/xanzy/terraform-api/terraform.MockResourceProvider.ResourcesReturn方法的典型用法代码示例。如果您正苦于以下问题:Golang MockResourceProvider.ResourcesReturn方法的具体用法?Golang MockResourceProvider.ResourcesReturn怎么用?Golang MockResourceProvider.ResourcesReturn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xanzy/terraform-api/terraform.MockResourceProvider
的用法示例。
在下文中一共展示了MockResourceProvider.ResourcesReturn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestResourceProvider_resources
func TestResourceProvider_resources(t *testing.T) {
p := new(terraform.MockResourceProvider)
client, server := testClientServer(t)
name, err := Register(server, p)
if err != nil {
t.Fatalf("err: %s", err)
}
provider := &ResourceProvider{Client: client, Name: name}
expected := []terraform.ResourceType{
{"foo"},
{"bar"},
}
p.ResourcesReturn = expected
// Resources
result := provider.Resources()
if !p.ResourcesCalled {
t.Fatal("resources should be called")
}
if !reflect.DeepEqual(result, expected) {
t.Fatalf("bad: %#v", result)
}
}
示例2: testProvider
func testProvider() *terraform.MockResourceProvider {
mp := new(terraform.MockResourceProvider)
mp.DiffReturn = &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"foo": &terraform.ResourceAttrDiff{
New: "bar",
},
},
}
mp.ResourcesReturn = []terraform.ResourceType{
terraform.ResourceType{Name: "test_instance"},
}
return mp
}
示例3: testProvider
func testProvider() *terraform.MockResourceProvider {
p := new(terraform.MockResourceProvider)
p.DiffReturn = &terraform.InstanceDiff{}
p.RefreshFn = func(
info *terraform.InstanceInfo,
s *terraform.InstanceState) (*terraform.InstanceState, error) {
return s, nil
}
p.ResourcesReturn = []terraform.ResourceType{
terraform.ResourceType{
Name: "test_instance",
},
}
return p
}