-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_test.go
61 lines (49 loc) · 1.21 KB
/
db_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
57
58
59
60
61
package main_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/jimmykarily/stratosphere"
)
var _ = Describe("Db", func() {
var (
path string
)
Describe("Creating a new DB object", func() {
Context("using a path to an existing file", func() {
BeforeEach(func() {
path = "fixtures/test.sqlite3"
})
It("should not return an error", func() {
_, err := NewDb(path)
Expect(err).To(BeNil())
})
})
Context("with a path to a non existent file", func() {
BeforeEach(func() {
path = "fixtures/not_a_file"
})
It("should return an error", func() {
_, err := NewDb(path)
Expect(err.Error()).To(Equal("Database file doesn't exist: fixtures/not_a_file"))
})
})
})
Describe("#Activities", func() {
var db *Db
BeforeEach(func() {
path = "fixtures/test.sqlite3"
db, _ = NewDb(path)
})
It("returns all Activities", func() {
activities, err := db.Activities()
Expect(err).To(BeNil())
Expect(len(activities)).To(Equal(30))
})
It("returns Activity objects", func() {
activities, err := db.Activities()
Expect(err).To(BeNil())
Expect(fmt.Sprintf("%T", activities[0])).To(Equal("*main.Activity"))
})
})
})