mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 22:40:31 -05:00
Added a few little tests
This commit is contained in:
parent
1ca34c4ecf
commit
3dc5e0e181
2 changed files with 29 additions and 0 deletions
|
@ -76,6 +76,10 @@ func TestEmailUsername(t *testing.T) {
|
||||||
input: emptyEmail,
|
input: emptyEmail,
|
||||||
expect: emptyEmail,
|
expect: emptyEmail,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: "",
|
||||||
|
expect: "",
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
if actual := emailUsername(test.input); actual != test.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)
|
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 a new issue