2017-09-08 16:11:41 +02:00
|
|
|
package gcs
|
2017-09-08 14:58:19 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestStateFile(t *testing.T) {
|
|
|
|
cases := []struct {
|
2017-09-11 08:25:42 +02:00
|
|
|
prefix string
|
2017-09-08 14:58:19 +02:00
|
|
|
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{
|
2017-09-11 08:25:42 +02:00
|
|
|
prefix: c.prefix,
|
2017-09-08 14:58:19 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|