20
20
package cloudstack
21
21
22
22
import (
23
+ "context"
23
24
"os"
24
25
"testing"
25
26
27
+ "github.com/hashicorp/terraform-plugin-go/tfprotov5"
28
+ "github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
26
29
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
30
+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
27
31
)
28
32
29
33
var testAccProviders map [string ]* schema.Provider
@@ -48,27 +52,47 @@ func TestProvider_impl(t *testing.T) {
48
52
var _ * schema.Provider = New ()
49
53
}
50
54
51
- func testSetValueOnResourceData (t * testing.T ) {
52
- d := schema.ResourceData {}
53
- d .Set ("id" , "name" )
55
+ func TestMuxServer (t * testing.T ) {
56
+ resource .Test (t , resource.TestCase {
57
+ ProtoV5ProviderFactories : map [string ]func () (tfprotov5.ProviderServer , error ){
58
+ "cloudstack" : func () (tfprotov5.ProviderServer , error ) {
59
+ ctx := context .Background ()
60
+ providers := []func () tfprotov5.ProviderServer {
61
+ New ().GRPCProvider ,
62
+ }
54
63
55
- setValueOrID ( & d , "id" , "name" , "54711781-274e-41b2-83c0-17194d0108f7" )
64
+ muxServer , err := tf5muxserver . NewMuxServer ( ctx , providers ... )
56
65
57
- if d .Get ("id" ).(string ) != "name" {
58
- t .Fatal ("err: 'id' does not match 'name'" )
59
- }
60
- }
66
+ if err != nil {
67
+ return nil , err
68
+ }
61
69
62
- func testSetIDOnResourceData (t * testing.T ) {
63
- d := schema.ResourceData {}
64
- d .Set ("id" , "54711781-274e-41b2-83c0-17194d0108f7" )
70
+ return muxServer .ProviderServer (), nil
71
+ },
72
+ },
73
+ Steps : []resource.TestStep {
74
+ {
75
+ Config : testMuxServerConfig_basic ,
76
+ },
77
+ },
78
+ })
79
+ }
65
80
66
- setValueOrID (& d , "id" , "name" , "54711781-274e-41b2-83c0-17194d0108f7" )
81
+ const testMuxServerConfig_basic = `
82
+ resource "cloudstack_zone" "zone_resource"{
83
+ name = "TestZone"
84
+ dns1 = "8.8.8.8"
85
+ internal_dns1 = "172.20.0.1"
86
+ network_type = "Advanced"
87
+ }
67
88
68
- if d .Get ("id" ).(string ) != "54711781-274e-41b2-83c0-17194d0108f7" {
69
- t .Fatal ("err: 'id' does not match '54711781-274e-41b2-83c0-17194d0108f7'" )
70
- }
71
- }
89
+ data "cloudstack_zone" "zone_data_source"{
90
+ filter{
91
+ name = "name"
92
+ value = cloudstack_zone.zone_resource.name
93
+ }
94
+ }
95
+ `
72
96
73
97
func testAccPreCheck (t * testing.T ) {
74
98
if v := os .Getenv ("CLOUDSTACK_API_URL" ); v == "" {
0 commit comments