forked from rethinkdb/rethinkdb-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_db_test.go
57 lines (42 loc) · 1.21 KB
/
query_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
package gorethink
import (
test "gopkg.in/check.v1"
)
func (s *RethinkSuite) TestDbCreate(c *test.C) {
// Delete the test2 database if it already exists
DBDrop("test").Exec(session)
// Test database creation
query := DBCreate("test")
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.DBsCreated, jsonEquals, 1)
}
func (s *RethinkSuite) TestDbList(c *test.C) {
var response []interface{}
// create database
DBCreate("test").Exec(session)
// Try and find it in the list
success := false
res, err := DBList().Run(session)
c.Assert(err, test.IsNil)
err = res.All(&response)
c.Assert(err, test.IsNil)
c.Assert(response, test.FitsTypeOf, []interface{}{})
for _, db := range response {
if db == "test" {
success = true
}
}
c.Assert(success, test.Equals, true)
}
func (s *RethinkSuite) TestDbDelete(c *test.C) {
// Delete the test2 database if it already exists
DBCreate("test").Exec(session)
// Test database creation
query := DBDrop("test")
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.DBsDropped, jsonEquals, 1)
// Ensure that there is still a test DB after the test has finished
DBCreate("test").Exec(session)
}