forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_json2dot_test.go
More file actions
53 lines (44 loc) · 986 Bytes
/
Copy pathdebug_json2dot_test.go
File metadata and controls
53 lines (44 loc) · 986 Bytes
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
package command
import (
"io/ioutil"
"os"
"strings"
"testing"
"github.com/hashicorp/terraform/dag"
"github.com/mitchellh/cli"
)
func TestDebugJSON2Dot(t *testing.T) {
// create the graph JSON output
logFile, err := ioutil.TempFile("", "tf")
if err != nil {
t.Fatal(err)
}
defer os.Remove(logFile.Name())
var g dag.Graph
g.SetDebugWriter(logFile)
g.Add(1)
g.Add(2)
g.Add(3)
g.Connect(dag.BasicEdge(1, 2))
g.Connect(dag.BasicEdge(2, 3))
ui := new(cli.MockUi)
c := &DebugJSON2DotCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
logFile.Name(),
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
output := ui.OutputWriter.String()
if !strings.HasPrefix(output, "digraph {") {
t.Fatalf("doesn't look like digraph: %s", output)
}
if !strings.Contains(output, `subgraph "root" {`) {
t.Fatalf("doesn't contains root subgraph: %s", output)
}
}