(t *testing.T)
| 27 | } |
| 28 | |
| 29 | func TestGraphToDOT(t *testing.T) { |
| 30 | g := dotSampleGraph() |
| 31 | include := selectFullGraphNodes(g) |
| 32 | dot := graphToDOT(g, include, "knowledge graph") |
| 33 | |
| 34 | for _, want := range []string{ |
| 35 | "graph knowledge {", |
| 36 | `"topic:auth" [label="auth"`, |
| 37 | `"fact:1"`, |
| 38 | " -- ", // an undirected edge |
| 39 | kindColor(knowledge.KindTopic), |
| 40 | kindColor(knowledge.KindSkill), |
| 41 | } { |
| 42 | if !strings.Contains(dot, want) { |
| 43 | t.Fatalf("DOT missing %q in:\n%s", want, dot) |
| 44 | } |
| 45 | } |
| 46 | // Edges are emitted once (deduped): exactly two among three nodes here. |
| 47 | if n := strings.Count(dot, " -- "); n != 2 { |
| 48 | t.Fatalf("expected 2 undirected edges, got %d:\n%s", n, dot) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestSelectFullGraphNodesSmallIncludesAll(t *testing.T) { |
| 53 | g := dotSampleGraph() |
nothing calls this directly
no test coverage detected