-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcouch_service_test.go
49 lines (45 loc) · 1014 Bytes
/
couch_service_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
49
package couchdb
import (
"testing"
)
func TestGetInstance(t *testing.T) {
testCases := []struct {
Name string
BaseURL string
Username string
Password string
ExpectedError bool
}{
{
Name: "Valid URL and authentication",
BaseURL: "https://example.com",
Username: "testuser",
Password: "testpassword",
ExpectedError: false,
},
{
Name: "Invalid URL scheme",
BaseURL: "example.com",
Username: "testuser",
Password: "testpassword",
ExpectedError: true,
},
{
Name: "Invalid base URL",
BaseURL: "invalidurl",
Username: "testuser",
Password: "testpassword",
ExpectedError: true,
},
}
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
defer func() {
if r := recover(); r != nil && !tc.ExpectedError {
t.Errorf("Unexpected panic: %v", r)
}
}()
_ = GetInstance(tc.BaseURL, tc.Username, tc.Password)
})
}
}