github.com/opentofu/opentofu@v1.7.1/internal/dag/dot_test.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package dag 7 8 import ( 9 "reflect" 10 "testing" 11 ) 12 13 func TestGraphDot_opts(t *testing.T) { 14 var v testDotVertex 15 var g Graph 16 g.Add(&v) 17 18 opts := &DotOpts{MaxDepth: 42} 19 actual := g.Dot(opts) 20 if len(actual) == 0 { 21 t.Fatal("should not be empty") 22 } 23 24 if !v.DotNodeCalled { 25 t.Fatal("should call DotNode") 26 } 27 if !reflect.DeepEqual(v.DotNodeOpts, opts) { 28 t.Fatalf("bad; %#v", v.DotNodeOpts) 29 } 30 } 31 32 type testDotVertex struct { 33 DotNodeCalled bool 34 DotNodeTitle string 35 DotNodeOpts *DotOpts 36 DotNodeReturn *DotNode 37 } 38 39 func (v *testDotVertex) DotNode(title string, opts *DotOpts) *DotNode { 40 v.DotNodeCalled = true 41 v.DotNodeTitle = title 42 v.DotNodeOpts = opts 43 return v.DotNodeReturn 44 }