Added a few little tests

This commit is contained in:
Matthew Holt 2015-11-15 10:55:15 -07:00
parent 1ca34c4ecf
commit 3dc5e0e181
2 changed files with 29 additions and 0 deletions

View File

@ -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
View 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)
}
}