forked from jonmorehouse/terraform-provisioner-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovisioner_test.go
42 lines (35 loc) · 945 Bytes
/
provisioner_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"io/ioutil"
"testing"
)
func createTmpDir(t *testing.T, directoryPrefix string) string {
d, err := ioutil.TempDir("", directoryPrefix)
if err != nil {
t.Fatalf("Unable to create temporary directory")
}
return d
}
func createTmpFile(t *testing.T, filenamePrefix string) string {
// by default, we want to use the operating system's choice of temporary directory
f, err := ioutil.TempFile("", filenamePrefix)
if err != nil {
t.Fatalf("Unable to create temporary file")
}
return f.Name()
}
func TestProvisioner_good(t *testing.T) {
p := &Provisioner{
Playbook: createTmpFile(t, "playbook"),
Plays: []string{"play1", "play2"},
ModulePath: createTmpDir(t, "ansible"),
Groups: []string{"all", "terraform"},
ExtraVars: map[string]string{
"key": "value",
},
}
if err := p.Validate(); err != nil {
t.Log(err)
t.Fatalf("unable to validate properly configured provisioner")
}
}