37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package gcs
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestStateFile(t *testing.T) {
|
|
cases := []struct {
|
|
prefix string
|
|
defaultStateFile string
|
|
name string
|
|
wantStateFile string
|
|
wantLockFile string
|
|
}{
|
|
{"state", "", "default", "state/default.tfstate", "state/default.tflock"},
|
|
{"state", "", "test", "state/test.tfstate", "state/test.tflock"},
|
|
{"state", "legacy.tfstate", "default", "legacy.tfstate", "legacy.tflock"},
|
|
{"state", "legacy.tfstate", "test", "state/test.tfstate", "state/test.tflock"},
|
|
{"state", "legacy.state", "default", "legacy.state", "legacy.state.tflock"},
|
|
{"state", "legacy.state", "test", "state/test.tfstate", "state/test.tflock"},
|
|
}
|
|
for _, c := range cases {
|
|
b := &gcsBackend{
|
|
prefix: c.prefix,
|
|
defaultStateFile: c.defaultStateFile,
|
|
}
|
|
|
|
if got := b.stateFile(c.name); got != c.wantStateFile {
|
|
t.Errorf("stateFile(%q) = %q, want %q", c.name, got, c.wantStateFile)
|
|
}
|
|
|
|
if got := b.lockFile(c.name); got != c.wantLockFile {
|
|
t.Errorf("lockFile(%q) = %q, want %q", c.name, got, c.wantLockFile)
|
|
}
|
|
}
|
|
}
|