Skip to content

Commit

Permalink
all functions consistent to use PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver.michels committed Apr 10, 2021
1 parent e1ef32a commit 00727ae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
38 changes: 19 additions & 19 deletions modules/azure/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ func GetPostgreSQLServerClientE(subscriptionID string) (*postgresql.ServersClien
return &postgresqlClient, nil
}

// GetPostgresqlServer is a helper function that gets the server.
// GetPostgreSQLServer is a helper function that gets the server.
// This function would fail the test if there is an error.
func GetPostgresqlServer(t testing.TestingT, resGroupName string, serverName string, subscriptionID string) *postgresql.Server {
postgresqlServer, err := GetPostgresqlServerE(t, subscriptionID, resGroupName, serverName)
func GetPostgreSQLServer(t testing.TestingT, resGroupName string, serverName string, subscriptionID string) *postgresql.Server {
postgresqlServer, err := GetPostgreSQLServerE(t, subscriptionID, resGroupName, serverName)
require.NoError(t, err)

return postgresqlServer
}

// GetPostgresqlServerE is a helper function that gets the server.
func GetPostgresqlServerE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) (*postgresql.Server, error) {
// GetPostgreSQLServerE is a helper function that gets the server.
func GetPostgreSQLServerE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) (*postgresql.Server, error) {
// Create a postgresql Server client
postgresqlClient, err := GetPostgreSQLServerClientE(subscriptionID)
if err != nil {
Expand All @@ -58,8 +58,8 @@ func GetPostgresqlServerE(t testing.TestingT, subscriptionID string, resGroupNam
return &postgresqlServer, nil
}

// GetPostgresqlDBClientE is a helper function that will setup a postgresql DB client.
func GetPostgresqlDBClientE(subscriptionID string) (*postgresql.DatabasesClient, error) {
// GetPostgreSQLDBClientE is a helper function that will setup a postgresql DB client.
func GetPostgreSQLDBClientE(subscriptionID string) (*postgresql.DatabasesClient, error) {
// Validate Azure subscription ID
subscriptionID, err := getTargetAzureSubscription(subscriptionID)
if err != nil {
Expand All @@ -81,19 +81,19 @@ func GetPostgresqlDBClientE(subscriptionID string) (*postgresql.DatabasesClient,
return &postgresqlDBClient, nil
}

//GetPostgresqlDB is a helper function that gets the database.
//GetPostgreSQLDB is a helper function that gets the database.
// This function would fail the test if there is an error.
func GetPostgresqlDB(t testing.TestingT, resGroupName string, serverName string, dbName string, subscriptionID string) *postgresql.Database {
database, err := GetPostgresqlDBE(t, subscriptionID, resGroupName, serverName, dbName)
func GetPostgreSQLDB(t testing.TestingT, resGroupName string, serverName string, dbName string, subscriptionID string) *postgresql.Database {
database, err := GetPostgreSQLDBE(t, subscriptionID, resGroupName, serverName, dbName)
require.NoError(t, err)

return database
}

//GetPostgresqlDBE is a helper function that gets the database.
func GetPostgresqlDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string, dbName string) (*postgresql.Database, error) {
//GetPostgreSQLDBE is a helper function that gets the database.
func GetPostgreSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string, dbName string) (*postgresql.Database, error) {
// Create a postgresql db client
postgresqldbClient, err := GetPostgresqlDBClientE(subscriptionID)
postgresqldbClient, err := GetPostgreSQLDBClientE(subscriptionID)
if err != nil {
return nil, err
}
Expand All @@ -108,18 +108,18 @@ func GetPostgresqlDBE(t testing.TestingT, subscriptionID string, resGroupName st
return &postgresqlDb, nil
}

//ListPostgresqlDB is a helper function that gets all databases per server.
func ListPostgresqlDB(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) []postgresql.Database {
dblist, err := ListPostgresqlDBE(t, subscriptionID, resGroupName, serverName)
//ListPostgreSQLDB is a helper function that gets all databases per server.
func ListPostgreSQLDB(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) []postgresql.Database {
dblist, err := ListPostgreSQLDBE(t, subscriptionID, resGroupName, serverName)
require.NoError(t, err)

return dblist
}

//ListPostgresqlDBE is a helper function that gets all databases per server.
func ListPostgresqlDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) ([]postgresql.Database, error) {
//ListPostgreSQLDBE is a helper function that gets all databases per server.
func ListPostgreSQLDBE(t testing.TestingT, subscriptionID string, resGroupName string, serverName string) ([]postgresql.Database, error) {
// Create a postgresql db client
postgresqldbClient, err := GetPostgresqlDBClientE(subscriptionID)
postgresqldbClient, err := GetPostgreSQLDBClientE(subscriptionID)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestGetPostgreSQLServerE(t *testing.T) {
serverName := ""
subscriptionID := ""

_, err := GetPostgresqlServerE(t, subscriptionID, resGroupName, serverName)
_, err := GetPostgreSQLServerE(t, subscriptionID, resGroupName, serverName)
require.Error(t, err)
}

Expand All @@ -35,6 +35,6 @@ func TestGetPostgreSQLDBE(t *testing.T) {
subscriptionID := ""
dbName := ""

_, err := GetPostgresqlDBE(t, subscriptionID, resGroupName, serverName, dbName)
_, err := GetPostgreSQLDBE(t, subscriptionID, resGroupName, serverName, dbName)
require.Error(t, err)
}
2 changes: 1 addition & 1 deletion test/azure/terraform_azure_postgresql_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestPostgreSQLDatabase(t *testing.T) {
expectedSkuName := terraform.Output(t, terraformOptions, "sku_name")

// website::tag::4:: Get the Server details and assert them against the terraform output
actualServer := azure.GetPostgresqlServer(t, rgName, actualServername, subscriptionID)
actualServer := azure.GetPostgreSQLServer(t, rgName, actualServername, subscriptionID)
// Verify
assert.NotNil(t, actualServer)
assert.Equal(t, expectedServername, actualServername)
Expand Down

0 comments on commit 00727ae

Please sign in to comment.