Merge pull request #26420 from remilapeyre/postgres-default-backend

Always have the default workspace in the pg backend
This commit is contained in:
Pam Selle 2020-09-30 17:54:24 -04:00 committed by GitHub
commit 3a99405b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -10,14 +10,16 @@ import (
)
func (b *Backend) Workspaces() ([]string, error) {
query := `SELECT name FROM %s.%s ORDER BY name`
query := `SELECT name FROM %s.%s WHERE name != 'default' ORDER BY name`
rows, err := b.db.Query(fmt.Sprintf(query, b.schemaName, statesTableName))
if err != nil {
return nil, err
}
defer rows.Close()
var result []string
result := []string{
backend.DefaultStateName,
}
for rows.Next() {
var name string

View File

@ -71,6 +71,8 @@ func TestBackendConfig(t *testing.T) {
if c.Name != backend.DefaultStateName {
t.Fatal("RemoteClient name is not configured")
}
backend.TestBackendStates(t, b)
}
func TestBackendConfigSkipSchema(t *testing.T) {

View File

@ -94,7 +94,7 @@ func TestBackendStates(t *testing.T, b Backend) {
// Test it starts with only the default
if !noDefault && (len(workspaces) != 1 || workspaces[0] != DefaultStateName) {
t.Fatalf("should only default to start: %#v", workspaces)
t.Fatalf("should only have the default workspace to start: %#v", workspaces)
}
// Create a couple states