-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_test.go
48 lines (37 loc) · 913 Bytes
/
database_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
package gocouchlib
import (
"fmt"
"net/url"
"testing"
)
func TestDatabaseCreateDelete(t *testing.T) {
s := &Server{"http://couchdb1:5984",
url.UserPassword("testuser", "password"),
}
db := &Database{"gocouch3", s}
isCreated, _ := db.Create()
fmt.Println("isCreated:", db.DbName, isCreated)
if !isCreated {
t.Error("DB creation failed")
}
// Test case: Database.Delete()
isDeleted, _ := db.Delete()
fmt.Println("isDeleted:", db.DbName, isDeleted)
}
func TestDatabaseExists(t *testing.T) {
// Test case: Database.Exists()
s := &Server{"http://couchdb1:5984",
url.UserPassword("testuser", "password"),
}
db := &Database{"gocouch", s}
if exists, _ := db.Exists(); !exists {
t.Error()
}
//Test case: Database.DbInfo()
dbInfo, _ := db.Info()
dbName := dbInfo.(map[string]interface{})["db_name"]
if dbName != "gocouch" {
t.Error()
}
fmt.Println("[Log]: DbName:", dbName)
}