Skip to content

Commit

Permalink
Add initial test coverage for #178
Browse files Browse the repository at this point in the history
  • Loading branch information
kylejohnson committed Sep 21, 2023
1 parent 5445d1e commit 26d632a
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 1,441 deletions.
9 changes: 5 additions & 4 deletions examples/issues/178/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "docker_image" "postgres" {

resource "docker_container" "postgres" {
image = docker_image.postgres.image_id
name = "postgres"
name = var.container_name
wait = true
ports {
internal = var.POSTGRES_PORT
Expand All @@ -52,12 +52,13 @@ provider "postgresql" {
username = var.POSTGRES_PASSWORD
password = var.POSTGRES_PASSWORD
sslmode = "disable"
superuser = false
superuser = var.superuser
}

resource "postgresql_database" "this" {
name = "test"
owner = var.POSTGRES_USER
name = var.database_name
template = var.database_template
owner = var.POSTGRES_USER
}

resource "postgresql_role" "readonly_role" {
Expand Down
28 changes: 28 additions & 0 deletions examples/issues/178/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,31 @@ variable "keep_image" {
type = bool
sensitive = false
}

variable "database_name" {
description = "Name for the database to be created."
default = "issue178"
type = string
sensitive = false
}

variable "database_template" {
description = "The name of the template database from which to create the database."
default = "template0"
type = string
sensitive = false
}

variable "superuser" {
description = "Whether the POSTGRES_USER is a PostgreSQL superuser."
default = false
type = bool
sensitive = false
}

variable "container_name" {
description = "The name for the docker container."
default = "postgres"
type = string
sensitive = false
}
21 changes: 20 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/terraform-providers/terraform-provider-postgresql

go 1.20
go 1.21.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0
Expand All @@ -9,6 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.18.32
github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.12
github.com/blang/semver v3.5.1+incompatible
github.com/gruntwork-io/terratest v0.44.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/lib/pq v1.10.9
github.com/sean-/postgresql-acl v0.0.0-20161225120419-d10489e5d217
Expand All @@ -19,14 +20,18 @@ require (
)

require (
cloud.google.com/go v0.110.7 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
cloud.google.com/go/storage v1.31.0 // indirect
contrib.go.opencensus.io/integrations/ocsql v0.1.7 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/GoogleCloudPlatform/cloudsql-proxy v1.33.9 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go v1.44.314 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.31 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.37 // indirect
Expand All @@ -37,6 +42,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.21.1 // indirect
github.com/aws/smithy-go v1.14.0 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand All @@ -52,9 +58,11 @@ require (
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.10 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.5.0 // indirect
Expand All @@ -67,17 +75,24 @@ require (
github.com/hashicorp/terraform-registry-address v0.2.1 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tmccombs/hcl2json v0.3.3 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand All @@ -88,11 +103,15 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.134.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
Loading

0 comments on commit 26d632a

Please sign in to comment.