-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap_test.go
56 lines (47 loc) · 1006 Bytes
/
bootstrap_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package sqlite
import (
"database/sql"
"testing"
"github.com/carlmjohnson/be"
vocab "github.com/go-ap/activitypub"
)
func checkInsertedValue(t *testing.T, db *sql.DB, actor vocab.Item) {
sel := "SELECT id, raw FROM objects WHERE id = ?;"
res, err := db.Query(sel, actor.GetLink())
be.NilErr(t, err)
be.Nonzero(t, res)
defer res.Close()
for res.Next() {
var id string
var raw []byte
err := res.Scan(&id, &raw)
be.NilErr(t, err)
be.Equal(t, actor.GetLink().String(), id)
incraw, err := vocab.MarshalJSON(actor)
be.NilErr(t, err)
be.Equal(t, string(incraw), string(raw))
}
}
func TestBootstrap(t *testing.T) {
tests := []struct {
name string
err error
}{
{
name: "noop",
err: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
conf := Config{
Path: t.TempDir(),
CacheEnable: false,
LogFn: t.Logf,
ErrFn: t.Errorf,
}
err := Bootstrap(conf)
checkErrorsEqual(t, tt.err, err)
})
}
}