-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_test.go
More file actions
45 lines (34 loc) · 796 Bytes
/
server_test.go
File metadata and controls
45 lines (34 loc) · 796 Bytes
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
package gocouchlib
import (
"fmt"
"net/url"
"strings"
"testing"
)
func TestServer(t *testing.T) {
// Test case: CouchDB URL without authentication credentials
s := &Server{"http://couchdb1:5984", nil}
fmt.Println(s.FullUrl())
if s.FullUrl() == "" {
t.Error()
}
// Test case: CouchDB URL with authentication credentials
s = &Server{"http://couchdb1:5984",
url.UserPassword("testuser", "password"),
}
fmt.Println(s.FullUrl())
if s.FullUrl() == "" || !strings.Contains(s.FullUrl(), "@") {
t.Error()
}
// Test case: Server.Info()
s = &Server{"http://couchdb1:5984",
url.UserPassword("testuser", "password"),
}
fmt.Println(s.Info())
// Test case: Server.AllDbs()
allDbs := s.AllDbs()
if len(allDbs.([]interface{})) == 0 {
t.Error()
}
fmt.Println(allDbs)
}