-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_test.go
38 lines (29 loc) · 904 Bytes
/
graph_test.go
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
32
33
34
35
36
37
38
package fixtures
import (
"bytes"
"testing"
"github.com/go-quicktest/qt"
)
func TestRepository_ImportOrder(t *testing.T) {
repo := New()
repo.Register(User{})
repo.Register(Transaction{})
repo.Register(Address{})
order, err := repo.importOrder()
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.HasLen(order, 3))
qt.Check(t, qt.DeepEquals(order, []string{"addresses", "users", "transactions"}))
}
func TestRepository_DrawDependencies(t *testing.T) {
repo := New()
repo.Register(User{})
repo.Register(Transaction{})
repo.Register(Address{})
var buf bytes.Buffer
err := repo.DrawDependencies(&buf)
qt.Assert(t, qt.IsNil(err))
// fmt.Println(buf.String())
qt.Check(t, qt.StringContains(buf.String(), `"transactions" -> "addresses"`))
qt.Check(t, qt.StringContains(buf.String(), `"transactions" -> "users"`))
qt.Check(t, qt.StringContains(buf.String(), `"users" -> "addresses"`))
}