github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/dag/dot_test.go (about)

     1  package dag
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestGraphDot_opts(t *testing.T) {
     9  	var v testDotVertex
    10  	var g Graph
    11  	g.Add(&v)
    12  
    13  	opts := &DotOpts{MaxDepth: 42}
    14  	actual := g.Dot(opts)
    15  	if len(actual) == 0 {
    16  		t.Fatal("should not be empty")
    17  	}
    18  
    19  	if !v.DotNodeCalled {
    20  		t.Fatal("should call DotNode")
    21  	}
    22  	if !reflect.DeepEqual(v.DotNodeOpts, opts) {
    23  		t.Fatalf("bad; %#v", v.DotNodeOpts)
    24  	}
    25  }
    26  
    27  type testDotVertex struct {
    28  	DotNodeCalled bool
    29  	DotNodeTitle  string
    30  	DotNodeOpts   *DotOpts
    31  	DotNodeReturn *DotNode
    32  }
    33  
    34  func (v *testDotVertex) DotNode(title string, opts *DotOpts) *DotNode {
    35  	v.DotNodeCalled = true
    36  	v.DotNodeTitle = title
    37  	v.DotNodeOpts = opts
    38  	return v.DotNodeReturn
    39  }