@@ -11,7 +11,7 @@ import (
11
11
)
12
12
13
13
func init () {
14
- os .Setenv ("TF_GRAPHQL_URL" , queryUrl )
14
+ // os.Setenv("TF_GRAPHQL_URL", queryUrl)
15
15
os .Setenv ("TF_ACC" , "1" )
16
16
}
17
17
@@ -20,14 +20,16 @@ func TestAccGraphqlMutation_full(t *testing.T) {
20
20
defer httpmock .DeactivateAndReset ()
21
21
22
22
httpmock .RegisterResponder ("POST" , queryUrl , mockGqlServerResponse )
23
+ httpmock .RegisterResponder ("POST" , queryUrlUpdate , mockGqlServerResponseUpdate )
23
24
24
25
resource .Test (t , resource.TestCase {
25
26
PreCheck : func () { testAccPreCheck (t ) },
26
27
Providers : testAccProviders ,
27
28
CheckDestroy : testAccGraphqlMutationResourceDestroy ,
28
29
Steps : []resource.TestStep {
29
30
{
30
- Config : resourceConfigCreate ,
31
+ Config : resourceConfigCreate ,
32
+ PreConfig : setupBasicCreate ,
31
33
Check : resource .ComposeTestCheckFunc (
32
34
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
33
35
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "something todo" ),
@@ -38,7 +40,8 @@ func TestAccGraphqlMutation_full(t *testing.T) {
38
40
),
39
41
},
40
42
{
41
- Config : resourceConfigUpdate ,
43
+ Config : resourceConfigUpdate ,
44
+ PreConfig : setupBasicUpdate ,
42
45
Check : resource .ComposeTestCheckFunc (
43
46
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
44
47
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "something else" ),
@@ -64,6 +67,7 @@ func TestAccGraphqlMutation_expectError(t *testing.T) {
64
67
Steps : []resource.TestStep {
65
68
{
66
69
Config : resourceConfigCreate ,
70
+ PreConfig : setupBasicCreate ,
67
71
ExpectError : regexp .MustCompile ("bad things happened" ),
68
72
},
69
73
},
@@ -82,7 +86,9 @@ func TestAccGraphqlMutation_computefromcreate(t *testing.T) {
82
86
CheckDestroy : testAccGraphqlMutationResourceDestroy ,
83
87
Steps : []resource.TestStep {
84
88
{
85
- Config : resourceConfigComputeMutationKeysOnCreate ,
89
+ Config : resourceConfigComputeMutationKeysOnCreate ,
90
+ PreConfig : setupBasicCreate ,
91
+ ExpectNonEmptyPlan : true ,
86
92
Check : resource .ComposeTestCheckFunc (
87
93
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "2" ),
88
94
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_delete_operation_variables.id" , "2" ),
@@ -100,14 +106,16 @@ func TestAccGraphqlMutation_force_replace(t *testing.T) {
100
106
defer httpmock .DeactivateAndReset ()
101
107
102
108
httpmock .RegisterResponder ("POST" , queryUrl , mockGqlServerResponse )
109
+ httpmock .RegisterResponder ("POST" , queryUrlUpdate , mockGqlServerResponseForceReplace )
103
110
104
111
resource .Test (t , resource.TestCase {
105
112
PreCheck : func () { testAccPreCheck (t ) },
106
113
Providers : testAccProviders ,
107
114
CheckDestroy : testAccGraphqlMutationResourceDestroy ,
108
115
Steps : []resource.TestStep {
109
116
{
110
- Config : resourceConfigCreate ,
117
+ Config : resourceConfigCreate ,
118
+ PreConfig : setupBasicCreate ,
111
119
Check : resource .ComposeTestCheckFunc (
112
120
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
113
121
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "something todo" ),
@@ -118,7 +126,8 @@ func TestAccGraphqlMutation_force_replace(t *testing.T) {
118
126
),
119
127
},
120
128
{
121
- Config : resourceConfigUpdateForceReplace ,
129
+ Config : resourceConfigUpdateForceReplace ,
130
+ PreConfig : setupBasicUpdate ,
122
131
Check : resource .ComposeTestCheckFunc (
123
132
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
124
133
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "forced replacement" ),
@@ -136,14 +145,16 @@ func TestAccGraphqlMutation_remote_verify_disable(t *testing.T) {
136
145
defer httpmock .DeactivateAndReset ()
137
146
138
147
httpmock .RegisterResponder ("POST" , queryUrl , mockGqlServerResponse )
148
+ httpmock .RegisterResponder ("POST" , queryUrlUpdate , mockGqlServerResponseRemoteStateVerifyDisabled )
139
149
140
150
resource .Test (t , resource.TestCase {
141
151
PreCheck : func () { testAccPreCheck (t ) },
142
152
Providers : testAccProviders ,
143
153
CheckDestroy : testAccGraphqlMutationResourceDestroy ,
144
154
Steps : []resource.TestStep {
145
155
{
146
- Config : resourceConfigCreateRemoteStateVerificationDisabled ,
156
+ Config : resourceConfigCreateRemoteStateVerificationDisabled ,
157
+ PreConfig : setupBasicCreate ,
147
158
Check : resource .ComposeTestCheckFunc (
148
159
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
149
160
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "something todo" ),
@@ -153,6 +164,18 @@ func TestAccGraphqlMutation_remote_verify_disable(t *testing.T) {
153
164
resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "query_response" , readDataResponse ),
154
165
),
155
166
},
167
+ {
168
+ Config : resourceConfigCreateRemoteStateVerificationDisabled ,
169
+ PreConfig : setupBasicUpdate ,
170
+ Check : resource .ComposeTestCheckFunc (
171
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.id" , "1" ),
172
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.text" , "something todo" ),
173
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_update_operation_variables.userId" , "900" ),
174
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_delete_operation_variables.id" , "1" ),
175
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "computed_delete_operation_variables.testvar1" , "testval1" ),
176
+ resource .TestCheckResourceAttr ("graphql_mutation.basic_mutation" , "query_response" , readDataResponseUpdateRemoteStateVerifyDisabled ),
177
+ ),
178
+ },
156
179
},
157
180
})
158
181
}
0 commit comments