forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet_test.go
48 lines (36 loc) · 1.1 KB
/
net_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 util
import (
"testing"
)
// DefaultPort appends given port to connection if not specified
func TestDefaultPort(t *testing.T) {
expect := "foo:7090"
if uri := DefaultPort("foo:7090", 7090); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
if uri := DefaultPort("foo", 7090); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
}
func TestDefaultScheme(t *testing.T) {
expect := "http://localhost"
if uri := DefaultScheme("localhost", "http"); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
if uri := DefaultScheme("http://localhost", "http"); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
if uri := DefaultScheme("http://localhost", "https"); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
expect = "ws://localhost:8080"
if uri := DefaultScheme("localhost:8080", "ws"); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
}
func TestDefaultSchemeWithEmptyUri(t *testing.T) {
expect := ""
if uri := DefaultScheme("", "http"); uri != expect {
t.Errorf("expected %s, got %s", expect, uri)
}
}