コード例 #1
0
func (s *S) TestCheckSessionsDisabled(c *C) {
	var server dbtest.DBServer
	server.SetPath(c.MkDir())
	defer server.Stop()

	os.Setenv("CHECK_SESSIONS", "0")

	// Should not panic, although it looks to Wipe like this session will leak.
	session := server.Session()
	defer session.Close()
	server.Wipe()
}
コード例 #2
0
func (s *S) TestWipeData(c *C) {
	var server dbtest.DBServer
	server.SetPath(c.MkDir())
	defer server.Stop()

	session := server.Session()
	err := session.DB("mydb").C("mycoll").Insert(M{"a": 1})
	session.Close()
	c.Assert(err, IsNil)

	server.Wipe()

	session = server.Session()
	names, err := session.DatabaseNames()
	session.Close()
	c.Assert(err, IsNil)
	for _, name := range names {
		if name != "local" && name != "admin" {
			c.Fatalf("Wipe should have removed this database: %s", name)
		}
	}
}