-
Notifications
You must be signed in to change notification settings - Fork 31
/
simple_test.go
55 lines (43 loc) · 1.25 KB
/
simple_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
package aranGO
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSimple(t *testing.T) {
// connect
s, err := Connect(TestServer, TestUsername, TestPassword, verbose)
assert.Nil(t, err)
// Create the db
s.CreateDB(TestDbName, nil)
defer s.DropDB(TestDbName)
db := s.DB(TestDbName)
assert.NotNil(t, db)
c := db.Col(TestCollection)
assert.NotNil(t, c)
// Save
var saveTestDoc DocTest
saveTestDoc.Text = TestString
err = c.Save(saveTestDoc)
assert.Nil(t, err)
// Any
TestDoc = DocTest{} // Clean TestDoc variable
err = c.Any(&TestDoc)
assert.Equal(t, TestDoc.Error, false)
assert.Equal(t, TestString, TestDoc.Text)
// First
TestDoc = DocTest{} // Clean TestDoc variable
err = c.First(map[string]interface{}{"Text": TestString}, &TestDoc)
assert.Equal(t, TestDoc.Error, false)
assert.Equal(t, TestString, TestDoc.Text)
// Example
TestDoc = DocTest{} // Clean TestDoc variable
cur, err := c.Example(map[string]interface{}{"Text" : TestString}, 0, 10)
assert.Equal(t, TestDoc.Error, false)
assert.Nil(t, err)
assert.NotNil(t, cur)
TestDoc = DocTest{} // Clean TestDoc variable
moreFiles := cur.FetchOne(&TestDoc)
assert.Equal(t, moreFiles, false)
assert.Equal(t, TestString, TestDoc.Text)
// need to add new functions!
}