backend/remote-state/gcloud: Add test for Backend.{state,lock}File().
This commit is contained in:
parent
5a4e2076e9
commit
93a55f15e9
|
@ -0,0 +1,36 @@
|
|||
package gcloud
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStateFile(t *testing.T) {
|
||||
cases := []struct {
|
||||
stateDir 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{
|
||||
stateDir: c.stateDir,
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue