github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/builder/graph_test.go (about) 1 package builder 2 3 import ( 4 "context" 5 "io/ioutil" 6 "testing" 7 8 "github.com/go-logr/logr" 9 "github.com/go-logr/logr/testr" 10 ) 11 12 func TestGraph(t *testing.T) { 13 ctx := logr.NewContext(context.Background(), testr.New(t)) 14 a, err := Build(ctx, "testdata/archive/helloc.tar.gz", func(o *buildOptions) { 15 o.run = false 16 }) 17 if err != nil { 18 t.Fatal(err) 19 } 20 t.Log("action", a) 21 t.Log("deps", a.Deps) 22 if len(a.Deps) != 1 { 23 t.Errorf("missing deps: %v", a.Deps) 24 } 25 26 dot, err := generateDot(a) 27 if err != nil { 28 t.Fatal(err) 29 } 30 t.Log(string(dot)) 31 32 svg, err := dotToSvg(dot) 33 if err != nil { 34 t.Fatal(err) 35 } 36 t.Log(string(svg)) 37 38 if len(svg) == 0 { 39 t.Error("missing svg") 40 } 41 42 if err := ioutil.WriteFile("graph.svg", svg, 0666); err != nil { 43 t.Fatal(err) 44 } 45 }