-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClientSettings_test.go
More file actions
54 lines (43 loc) · 1.35 KB
/
ClientSettings_test.go
File metadata and controls
54 lines (43 loc) · 1.35 KB
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
50
51
52
53
54
package jrm1
import (
"testing"
"github.com/vault-thirteen/auxie/tester"
)
func Test_NewClientSettings(t *testing.T) {
aTest := tester.New(t)
var cs *ClientSettings
var err error
// Test #1. Check error.
cs, err = NewClientSettings("", "", 0, "", nil, nil, false)
aTest.MustBeAnError(err)
aTest.MustBeEqual(cs, (*ClientSettings)(nil))
// Test #2. All clear.
cs, err = NewClientSettings("http", "localhost", 80, "/", nil, nil, false)
aTest.MustBeNoError(err)
aTest.MustBeDifferent(cs, (*ClientSettings)(nil))
}
func Test_ClientSettings_Check(t *testing.T) {
aTest := tester.New(t)
var cs *ClientSettings
var err error
// Test #1. Schema is not set.
cs = &ClientSettings{schema: "", host: "localhost", port: 80, path: "/"}
err = cs.Check()
aTest.MustBeAnError(err)
// Test #2. Host is not set.
cs = &ClientSettings{schema: "http", host: "", port: 80, path: "/"}
err = cs.Check()
aTest.MustBeAnError(err)
// Test #3. Port is not set.
cs = &ClientSettings{schema: "http", host: "localhost", port: 0, path: "/"}
err = cs.Check()
aTest.MustBeAnError(err)
// Test #4. Path is not set.
cs = &ClientSettings{schema: "http", host: "localhost", port: 80, path: ""}
err = cs.Check()
aTest.MustBeAnError(err)
// Test #5. All clear.
cs = &ClientSettings{schema: "http", host: "localhost", port: 80, path: "/"}
err = cs.Check()
aTest.MustBeNoError(err)
}