Implement Read Only mode
This commit is contained in:
parent
6464d92dd4
commit
e1bd235785
19 changed files with 544 additions and 335 deletions
|
@ -1,6 +1,10 @@
|
|||
package database
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
mgo "gopkg.in/mgo.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
test_coll = "test_trantor"
|
||||
|
@ -12,29 +16,9 @@ func TestInit(t *testing.T) {
|
|||
defer db.Close()
|
||||
}
|
||||
|
||||
func TestCopy(t *testing.T) {
|
||||
db := Init(test_host, test_coll)
|
||||
defer db.del()
|
||||
|
||||
db2 := db.Copy()
|
||||
|
||||
if db.name != db2.name {
|
||||
t.Errorf("Names don't match")
|
||||
}
|
||||
names1, err := db.session.DatabaseNames()
|
||||
if err != nil {
|
||||
t.Errorf("Error on db1: ", err)
|
||||
}
|
||||
names2, err := db2.session.DatabaseNames()
|
||||
if err != nil {
|
||||
t.Errorf("Error on db1: ", err)
|
||||
}
|
||||
if len(names1) != len(names2) {
|
||||
t.Errorf("len(names) don't match")
|
||||
}
|
||||
for i, _ := range names1 {
|
||||
if names1[i] != names2[i] {
|
||||
t.Errorf("Names don't match")
|
||||
}
|
||||
}
|
||||
func del(db DB) {
|
||||
db.Close()
|
||||
session, _ := mgo.Dial(test_host)
|
||||
defer session.Close()
|
||||
session.DB(test_coll).DropDatabase()
|
||||
}
|
||||
|
|
Reference in a new issue