-
Notifications
You must be signed in to change notification settings - Fork 2
/
data_source_quantum_file_test.go
59 lines (54 loc) · 1.19 KB
/
data_source_quantum_file_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"io/ioutil"
"os"
"testing"
r "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestFile_basic(t *testing.T) {
var cases = []struct {
path string
content string
config string
}{
{
"quantum_file",
"This is some content",
`data "quantum_file" "file" {
content = "This is some content"
filename = "quantum_file"
}`,
},
{
"quantum_file",
"This is some sensitive content",
`data "quantum_file" "file" {
sensitive_content = "This is some sensitive content"
filename = "quantum_file"
}`,
},
}
for _, tt := range cases {
r.UnitTest(t, r.TestCase{
Providers: testProviders,
Steps: []r.TestStep{
{
Config: tt.config,
Check: func(s *terraform.State) error {
content, err := ioutil.ReadFile(tt.path)
if err != nil {
return fmt.Errorf("config:\n%s\n,got: %s\n", tt.config, err)
}
if string(content) != tt.content {
return fmt.Errorf("config:\n%s\ngot:\n%s\nwant:\n%s\n", tt.config, content, tt.content)
}
return nil
},
},
},
})
}
os.Remove("quantum_file")
}