File: query_admin_test.go

package info (click to toggle)
golang-gopkg-dancannon-gorethink.v1 1.4.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 764 kB
  • sloc: makefile: 3
file content (110 lines) | stat: -rw-r--r-- 2,613 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package gorethink

import (
	test "gopkg.in/check.v1"
)

func (s *RethinkSuite) TestAdminDbConfig(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	// Test index rename
	query := DB("test").Table("test").Config()

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["name"], test.Equals, "test")
}

func (s *RethinkSuite) TestAdminTableConfig(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	// Test index rename
	query := DB("test").Config()

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["name"], test.Equals, "test")
}

func (s *RethinkSuite) TestAdminTableStatus(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	// Test index rename
	query := DB("test").Table("test").Status()

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["name"], test.Equals, "test")
	c.Assert(response["status"], test.NotNil)
}

func (s *RethinkSuite) TestAdminWait(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	// Test index rename
	query := Wait()

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["ready"].(float64) > 0, test.Equals, true)
}

func (s *RethinkSuite) TestAdminWaitOpts(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	query := DB("test").Table("test").Wait(WaitOpts{
		WaitFor: "all_replicas_ready",
		Timeout: 10,
	})

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["ready"].(float64) > 0, test.Equals, true)
}

func (s *RethinkSuite) TestAdminStatus(c *test.C) {
	DB("test").TableDrop("test").Exec(session)
	DB("test").TableCreate("test").Exec(session)

	// Test index rename
	query := DB("test").Table("test").Wait()

	res, err := query.Run(session)
	c.Assert(err, test.IsNil)

	var response map[string]interface{}
	err = res.One(&response)
	c.Assert(err, test.IsNil)

	c.Assert(response["ready"], test.Equals, float64(1))
}