From 7e41f6ed62278cebef0eaeefe26f22ba62528e05 Mon Sep 17 00:00:00 2001 From: "Marcelo E. Magallon" Date: Tue, 20 Oct 2015 05:13:00 -0600 Subject: [PATCH 1/2] Add TestNewDefault to config tests Very simple test to make sure that NewDefault is populating the correct fields with the correct values. --- config/config_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/config_test.go b/config/config_test.go index a2c4f961..1753030b 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -8,6 +8,20 @@ import ( "github.com/mholt/caddy/server" ) +func TestNewDefault(t *testing.T) { + config := NewDefault() + + if actual, expected := config.Root, DefaultRoot; actual != expected { + t.Errorf("Root was %s but expected %s", actual, expected) + } + if actual, expected := config.Host, DefaultHost; actual != expected { + t.Errorf("Host was %s but expected %s", actual, expected) + } + if actual, expected := config.Port, DefaultPort; actual != expected { + t.Errorf("Port was %d but expected %d", actual, expected) + } +} + func TestResolveAddr(t *testing.T) { // NOTE: If tests fail due to comparing to string "127.0.0.1", // it's possible that system env resolves with IPv6, or ::1. From 8f9f6caa4e5527fb1c5f3d8cea631ff6657139df Mon Sep 17 00:00:00 2001 From: Marcelo Magallon Date: Tue, 20 Oct 2015 10:31:21 -0600 Subject: [PATCH 2/2] Update config_test.go --- config/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config_test.go b/config/config_test.go index 1753030b..7e476359 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -18,7 +18,7 @@ func TestNewDefault(t *testing.T) { t.Errorf("Host was %s but expected %s", actual, expected) } if actual, expected := config.Port, DefaultPort; actual != expected { - t.Errorf("Port was %d but expected %d", actual, expected) + t.Errorf("Port was %s but expected %s", actual, expected) } }