apply-test

This commit is contained in:
James Bardin 2017-02-03 14:55:13 -05:00
parent a2b5811f50
commit 6a20c35d61
1 changed files with 32 additions and 0 deletions

View File

@ -8,10 +8,12 @@ import (
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"reflect"
"strings"
"sync"
"syscall"
"testing"
"time"
@ -59,6 +61,36 @@ func TestApply(t *testing.T) {
}
}
// test apply with locked state
func TestApply_lockedState(t *testing.T) {
statePath := testTempFile(t)
locker := exec.Command("go", "run", "testadata/statelocker.go", statePath)
locker.Stderr = os.Stderr
if err := locker.Start(); err != nil {
t.Fatal(err)
}
defer locker.Process.Signal(syscall.SIGTERM)
p := testProvider()
ui := new(cli.MockUi)
c := &ApplyCommand{
Meta: Meta{
ContextOpts: testCtxConfig(p),
Ui: ui,
},
}
args := []string{
"-state", statePath,
testFixturePath("apply"),
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
}
// high water mark counter
type hwm struct {
sync.Mutex