Change the default for `valid_until` to `infinity` to match the default.

This commit is contained in:
Sean Chittenden 2016-12-12 01:18:13 -08:00
parent e9dc92c18d
commit e36827c5fe
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
2 changed files with 5 additions and 5 deletions

View File

@ -65,10 +65,10 @@ func resourcePostgreSQLRole() *schema.Resource {
Default: true,
Description: "Control whether the password is stored encrypted in the system catalogs",
},
roleValidUntilAttr: {
Type: schema.TypeString,
Optional: true,
Default: "infinity",
Description: "Sets a date and time after which the role's password is no longer valid",
},
roleConnLimitAttr: {
@ -188,8 +188,8 @@ func resourcePostgreSQLRoleCreate(d *schema.ResourceData, meta interface{}) erro
}
case opt.hclKey == roleValidUntilAttr:
switch {
case v.(string) == "", strings.ToUpper(v.(string)) == "NULL":
createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, "'infinity'"))
case v.(string) == "", strings.ToLower(v.(string)) == "infinity":
createOpts = append(createOpts, fmt.Sprintf("%s '%s'", opt.sqlKey, "infinity"))
default:
createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, pq.QuoteIdentifier(val)))
}

View File

@ -46,7 +46,7 @@ func TestAccPostgresqlRole_Basic(t *testing.T) {
resource.TestCheckResourceAttr(
"postgresql_role.role_with_defaults", "password", ""),
resource.TestCheckResourceAttr(
"postgresql_role.role_with_defaults", "valid_until", "NULL"),
"postgresql_role.role_with_defaults", "valid_until", "infinity"),
),
},
},
@ -165,6 +165,6 @@ resource "postgresql_role" "role_with_defaults" {
connection_limit = -1
encrypted_password = true
password = ""
valid_until = "NULL"
valid_until = "infinity"
}
`