-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_read_graph_test.go
More file actions
31 lines (27 loc) · 875 Bytes
/
tool_read_graph_test.go
File metadata and controls
31 lines (27 loc) · 875 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
package main
import (
"path/filepath"
"testing"
)
func TestToolReadGraph_Basic(t *testing.T) {
dir := t.TempDir()
p := filepath.Join(dir, "memory.db")
bolt := p + ".bolt"
m := NewGraphManager(p, bolt)
if _, err := m.CreateEntities([]Entity{{Name: "A", EntityType: "t", Observations: []string{"o1"}}, {Name: "B", EntityType: "t"}}); err != nil {
t.Fatalf("CreateEntities: %v", err)
}
if _, err := m.CreateRelations([]Relation{{From: "A", To: "B", RelationType: "likes"}}); err != nil {
t.Fatalf("CreateRelations: %v", err)
}
g, err := m.ReadGraph()
if err != nil {
t.Fatalf("ReadGraph: %v", err)
}
if len(g.Entities) != 2 {
t.Fatalf("want 2 entities, got %d", len(g.Entities))
}
if len(g.Relations) != 1 {
t.Fatalf("want 1 relation, got %d", len(g.Relations))
}
}