You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
t.Fatalf("unexpected error when loading test config: %s", loadDiags.Err())
2093
+
createDefaultWorkspacebool
2094
+
// assertions
2095
+
expectedErrorstring
2096
+
expectDefaultWorkspaceExistsbool
2097
+
}{
2098
+
"an init command prompts users for input when the default workspace needs to be created": {
2099
+
inputEnabled: true,
2100
+
createDefaultWorkspace: true,
2101
+
inputText: "yes",
2102
+
isInitCommand: true,
2103
+
expectDefaultWorkspaceExists: true,
2104
+
},
2105
+
"an init command with input disabled will create the default workspace automatically": {
2106
+
inputEnabled: false,
2107
+
createDefaultWorkspace: true,
2108
+
isInitCommand: true,
2109
+
expectDefaultWorkspaceExists: true,
2110
+
},
2111
+
"an init command with input disabled and the flag -create-default-workspace=false will not make the default workspace": {
2112
+
inputEnabled: false,
2113
+
createDefaultWorkspace: false,
2114
+
isInitCommand: true,
2115
+
expectDefaultWorkspaceExists: false,
2116
+
},
2117
+
// "during a non-init command, the command ends in with an error telling the user to run an init command": {
2118
+
// isInitCommand: false,
2119
+
// expectedError: "State store initialization required, please run \"terraform init\": Reason: Initial configuration of the requested state_store \"foo_bar\" in provider foo (\"registry.terraform.io/my-org/foo\")",
2120
+
// },
2100
2121
}
2101
2122
2102
-
// Get mock provider factory to be used during init
2103
-
//
2104
-
// This imagines a provider called foo that contains
2105
-
// a pluggable state store implementation called bar.
t.Fatalf("backend state file contains unexpected raw config data for the provider, want %q, got %q", expectedProviderConfig, cleanString(string(s.StateStore.Provider.ConfigRaw)))
t.Fatalf("backend state file contains unexpected raw config data for the state store, want %q, got %q", expectedStoreConfig, cleanString(string(s.StateStore.ConfigRaw)))
2153
+
// Create locks - these would normally be the locks derived from config
t.Fatalf("backend state file contains unexpected raw config data for the provider, want %q, got %q", expectedProviderConfig, cleanString(string(s.StateStore.Provider.ConfigRaw)))
t.Fatalf("backend state file contains unexpected raw config data for the state store, want %q, got %q", expectedStoreConfig, cleanString(string(s.StateStore.ConfigRaw)))
2211
+
}
2212
+
2213
+
w, wDiags:=b.Workspaces()
2214
+
ifwDiags.HasErrors() {
2215
+
t.Fatalf("unexpected error: %s", wDiags.Err())
2216
+
}
2217
+
iflen(w) ==0 {
2218
+
iftc.expectDefaultWorkspaceExists {
2219
+
t.Fatal("expected the default workspace to exist, but there are no workspaces")
2220
+
}
2221
+
return
2222
+
}
2223
+
iflen(w) >0 {
2224
+
iftc.expectDefaultWorkspaceExists {
2225
+
iflen(w) ==1&&w[0] !="default" {
2226
+
t.Fatalf("expected the default workspace to exist, but instead got: %v", w)
2227
+
}
2228
+
}
2229
+
t.Fatalf("expected the default workspace to be the only existing workspace, but instead got: %v", w)
0 commit comments