-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add on_account to session and object params (#1685)
* add on_account to session and object params * add on_account to session and object params * fix parameters data source acc tests * refactor parameters to remove code duplication * refactor parameters to remove code duplication
- Loading branch information
1 parent
edc7fd6
commit 1329430
Showing
14 changed files
with
424 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
resource "snowflake_session_parameter" "s" { | ||
key = "AUTOCOMMIT" | ||
value = "false" | ||
user = "TEST_USER" | ||
} | ||
|
||
resource "snowflake_session_parameter" "s2" { | ||
key = "BINARY_OUTPUT_FORMAT" | ||
value = "BASE64" | ||
on_account = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,100 @@ | ||
package datasources_test | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAcc_Parameters(t *testing.T) { | ||
func TestAcc_ParametersOnAccount(t *testing.T) { | ||
resource.ParallelTest(t, resource.TestCase{ | ||
Providers: providers(), | ||
CheckDestroy: nil, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: parameters(), | ||
Config: parametersConfigOnAccount(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "pattern", "AUTOCOMMIT"), | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "parameters.#", "1"), | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "parameters.0.key", "AUTOCOMMIT"), | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.value"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAcc_ParametersOnSession(t *testing.T) { | ||
userName := "TEST_USER_" + strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) | ||
resource.ParallelTest(t, resource.TestCase{ | ||
Providers: providers(), | ||
CheckDestroy: nil, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: parametersConfigOnSession(userName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.#"), | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.key"), | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.value"), | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "user", userName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func parameters() string { | ||
return `data "snowflake_parameters" "p" {}` | ||
func TestAcc_ParametersOnObject(t *testing.T) { | ||
dbName := "TEST_DB_" + strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) | ||
resource.ParallelTest(t, resource.TestCase{ | ||
Providers: providers(), | ||
CheckDestroy: nil, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: parametersConfigOnObject(dbName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.#"), | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.key"), | ||
resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.value"), | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "object_type", "DATABASE"), | ||
resource.TestCheckResourceAttr("data.snowflake_parameters.p", "object_name", dbName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func parametersConfigOnAccount() string { | ||
return `data "snowflake_parameters" "p" { | ||
parameter_type = "ACCOUNT" | ||
pattern = "AUTOCOMMIT" | ||
}` | ||
} | ||
|
||
func parametersConfigOnSession(user string) string { | ||
s := ` | ||
resource "snowflake_user" "u" { | ||
name = "%s" | ||
} | ||
data "snowflake_parameters" "p" { | ||
parameter_type = "SESSION" | ||
user = snowflake_user.u.name | ||
}` | ||
return fmt.Sprintf(s, user) | ||
} | ||
|
||
func parametersConfigOnObject(name string) string { | ||
stmt := ` | ||
resource "snowflake_database" "d" { | ||
name = "%s" | ||
} | ||
data "snowflake_parameters" "p" { | ||
parameter_type = "OBJECT" | ||
object_type = "DATABASE" | ||
object_name = snowflake_database.d.name | ||
}` | ||
return fmt.Sprintf(stmt, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.