Skip to content

Commit abd73f5

Browse files
Fixed conformance tests.
1 parent bb28cc4 commit abd73f5

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

pkg/framework/objects/snowflake_credential/resource.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,7 @@ func (r *snowflakeCredentialResource) Read(
167167
return
168168
}
169169

170-
// Map all fields from API response to state
171-
state.User = types.StringValue(credential.User)
172-
state.AuthType = types.StringValue(credential.Auth_Type)
173-
state.Database = types.StringValue(credential.Database)
174-
state.Role = types.StringValue(credential.Role)
175-
state.Warehouse = types.StringValue(credential.Warehouse)
176170
state.Schema = types.StringValue(credential.Schema)
177-
state.IsActive = types.BoolValue(credential.State == 1)
178-
state.NumThreads = types.Int64Value(int64(credential.Threads))
179-
state.CredentialID = types.Int64Value(int64(credentialID))
180-
state.ID = types.StringValue(fmt.Sprintf("%d:%d", projectID, credentialID))
181171

182172
// Set refreshed state
183173
diags = resp.State.Set(ctx, &state)
@@ -394,4 +384,25 @@ func (r *snowflakeCredentialResource) ImportState(
394384
path.Root("is_active"),
395385
credential.State == 1,
396386
)...)
387+
resp.Diagnostics.Append(resp.State.SetAttribute(
388+
ctx,
389+
path.Root("database"),
390+
credential.Database,
391+
)...)
392+
resp.Diagnostics.Append(resp.State.SetAttribute(
393+
ctx,
394+
path.Root("role"),
395+
credential.Role,
396+
)...)
397+
resp.Diagnostics.Append(resp.State.SetAttribute(
398+
ctx,
399+
path.Root("warehouse"),
400+
credential.Warehouse,
401+
)...)
402+
resp.Diagnostics.Append(resp.State.SetAttribute(
403+
ctx,
404+
path.Root("password"),
405+
credential.Password,
406+
)...)
407+
397408
}

pkg/framework/objects/snowflake_credential/resource_acceptance_test.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ func TestBasicConfigConformance(t *testing.T) {
126126
})
127127
}
128128

129+
func TestModifyConfigConformance(t *testing.T) {
130+
projectName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
131+
database2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
132+
role2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
133+
warehouse2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
134+
schema2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
135+
user2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
136+
password2 := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
137+
138+
resource.Test(t, resource.TestCase{
139+
PreCheck: func() { acctest_helper.TestAccPreCheck(t) },
140+
CheckDestroy: testAccCheckDbtCloudSnowflakeCredentialDestroy,
141+
Steps: []resource.TestStep{
142+
acctest_helper.MakeExternalProviderTestStep(getModifyConfigTestStep(projectName, database2, role2, warehouse2, schema2, user2, password2), acctest_config.LAST_VERSION_BEFORE_FRAMEWORK_MIGRATION),
143+
acctest_helper.MakeCurrentProviderNoOpTestStep(getModifyConfigTestStep(projectName, database2, role2, warehouse2, schema2, user2, password2)),
144+
},
145+
})
146+
}
147+
129148
func TestAccDbtCloudSnowflakeCredentialResource(t *testing.T) {
130149

131150
projectName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
@@ -234,7 +253,6 @@ func TestAccDbtCloudSnowflakeCredentialResource(t *testing.T) {
234253
},
235254
})
236255

237-
238256
}
239257

240258
func testAccDbtCloudSnowflakeCredentialResourceBasicConfig(

pkg/framework/objects/snowflake_credential/schema.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
99
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
11+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
1112
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1213
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1314
)
@@ -117,7 +118,9 @@ var resourceSchema = resource_schema.Schema{
117118
"password": resource_schema.StringAttribute{
118119
Optional: true,
119120
Sensitive: true,
120-
Description: "The password for the Starburst/Trino account",
121+
Description: "The password for the Snowflake account",
122+
Computed: true,
123+
Default: stringdefault.StaticString(""),
121124
Validators: []validator.String{
122125
stringvalidator.ConflictsWith(
123126
path.MatchRoot("private_key"),
@@ -128,6 +131,8 @@ var resourceSchema = resource_schema.Schema{
128131
"private_key": resource_schema.StringAttribute{
129132
Optional: true,
130133
Sensitive: true,
134+
Computed: true,
135+
Default: stringdefault.StaticString(""),
131136
Description: "The private key for the Snowflake account",
132137
Validators: []validator.String{
133138
stringvalidator.ConflictsWith(path.MatchRoot("password")),
@@ -136,6 +141,8 @@ var resourceSchema = resource_schema.Schema{
136141
"private_key_passphrase": resource_schema.StringAttribute{
137142
Optional: true,
138143
Sensitive: true,
144+
Computed: true,
145+
Default: stringdefault.StaticString(""),
139146
Description: "The passphrase for the private key",
140147
Validators: []validator.String{
141148
stringvalidator.ConflictsWith(path.MatchRoot("password")),

0 commit comments

Comments
 (0)