mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 17:56:34 +08:00
Added a few little tests
This commit is contained in:
parent
1ca34c4ecf
commit
3dc5e0e181
|
@ -76,6 +76,10 @@ func TestEmailUsername(t *testing.T) {
|
|||
input: emptyEmail,
|
||||
expect: emptyEmail,
|
||||
},
|
||||
{
|
||||
input: "",
|
||||
expect: "",
|
||||
},
|
||||
} {
|
||||
if actual := emailUsername(test.input); actual != test.expect {
|
||||
t.Errorf("Test %d: Expected username to be '%s' but was '%s'", i, test.expect, actual)
|
||||
|
|
25
server/config_test.go
Normal file
25
server/config_test.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package server
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestConfigAddress(t *testing.T) {
|
||||
cfg := Config{Host: "foobar", Port: "1234"}
|
||||
if actual, expected := cfg.Address(), "foobar:1234"; expected != actual {
|
||||
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
||||
}
|
||||
|
||||
cfg = Config{Host: "", Port: "1234"}
|
||||
if actual, expected := cfg.Address(), ":1234"; expected != actual {
|
||||
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
||||
}
|
||||
|
||||
cfg = Config{Host: "foobar", Port: ""}
|
||||
if actual, expected := cfg.Address(), "foobar:"; expected != actual {
|
||||
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
||||
}
|
||||
|
||||
cfg = Config{Host: "::1", Port: "https"}
|
||||
if actual, expected := cfg.Address(), "[::1]:https"; expected != actual {
|
||||
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user