2020package cloudstack
2121
2222import (
23+ "context"
2324 "os"
2425 "testing"
2526
27+ "github.com/hashicorp/terraform-plugin-go/tfprotov5"
28+ "github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
2629 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
30+ "github.com/hashicorp/terraform-plugin-testing/helper/resource"
2731)
2832
2933var testAccProviders map [string ]* schema.Provider
@@ -48,27 +52,47 @@ func TestProvider_impl(t *testing.T) {
4852 var _ * schema.Provider = New ()
4953}
5054
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+ }
5463
55- setValueOrID ( & d , "id" , "name" , "54711781-274e-41b2-83c0-17194d0108f7" )
64+ muxServer , err := tf5muxserver . NewMuxServer ( ctx , providers ... )
5665
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+ }
6169
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+ }
6580
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+ }
6788
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+ `
7296
7397func testAccPreCheck (t * testing.T ) {
7498 if v := os .Getenv ("CLOUDSTACK_API_URL" ); v == "" {
0 commit comments