-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathregress_hcloud_175_test.go
126 lines (116 loc) · 3.16 KB
/
regress_hcloud_175_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2016-2023, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tests
import (
"context"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
testutils "github.com/pulumi/providertest/replay"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)
func TestRegressHCloud175(t *testing.T) {
ctx := context.Background()
subnetResource := func() *schema.Resource {
return &schema.Resource{
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"network_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
},
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"network_zone": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"ip_range": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"gateway": {
Type: schema.TypeString,
Computed: true,
},
"vswitch_id": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
},
}
}
tfProvider := &schema.Provider{
Schema: map[string]*schema.Schema{},
ResourcesMap: map[string]*schema.Resource{
"hcloud_subnet": subnetResource(),
},
}
p := shimv2.NewProvider(tfProvider, shimv2.WithDiffStrategy(shimv2.PlanState))
info := tfbridge.ProviderInfo{
P: p,
Name: "hcloud",
Description: "etc",
Keywords: []string{"pulumi", "hcloud"},
License: "Apache-2.0",
Version: "0.0.1",
Resources: map[string]*tfbridge.ResourceInfo{
"hcloud_subnet": {Tok: "hcloud:index/networkSubnet:NetworkSubnet"},
},
}
server := tfbridge.NewProvider(ctx,
nil, /* hostClient */
"hcloud", /* module */
"", /* version */
p, /* tf */
info, /* info */
[]byte{}, /* pulumiSchema */
)
testCase := `
{
"method": "/pulumirpc.ResourceProvider/Create",
"request": {
"urn": "urn:pulumi:dev::repro-175::hcloud:index/networkSubnet:NetworkSubnet::subnet",
"properties": {
"__defaults": [],
"ipRange": "10.0.1.0/24",
"networkId": "04da6b54-80e4-46f7-96ec-b56ff0331ba9",
"networkZone": "eu-central",
"type": "cloud"
},
"preview": true
},
"response": {
"properties": {
"id": "*",
"ipRange": "10.0.1.0/24",
"networkZone": "eu-central",
"type": "cloud",
"gateway": "*",
"vswitchId": "*",
"networkId": "*"
}
}
}`
testutils.Replay(t, server, testCase)
}