From 3dc5e0e1818c189994053a4ee69e575248318b6a Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 15 Nov 2015 10:55:15 -0700 Subject: [PATCH] Added a few little tests --- caddy/letsencrypt/storage_test.go | 4 ++++ server/config_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 server/config_test.go diff --git a/caddy/letsencrypt/storage_test.go b/caddy/letsencrypt/storage_test.go index 5107c32ab..95fb71833 100644 --- a/caddy/letsencrypt/storage_test.go +++ b/caddy/letsencrypt/storage_test.go @@ -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) diff --git a/server/config_test.go b/server/config_test.go new file mode 100644 index 000000000..d94f3581e --- /dev/null +++ b/server/config_test.go @@ -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) + } +}