git » gofer » commit b7efbea

config: Add test to validate the example config

author Alberto Bertogli
2025-03-29 19:27:18 UTC
committer Alberto Bertogli
2025-03-29 19:28:01 UTC
parent 399f0c291825d35bacf25b7ee8a455934dc6d03c

config: Add test to validate the example config

This patch adds a test to the config package, which ensures that the
example config loads and checks without errors.

config/config_test.go +14 -0

diff --git a/config/config_test.go b/config/config_test.go
index 8b564e1..e9d7d02 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -112,6 +112,20 @@ https:
 	}
 }
 
+func TestExampleConfig(t *testing.T) {
+	// Test that we can load the included example config.
+	c, err := Load("gofer.yaml")
+	if err != nil {
+		t.Fatalf("error loading example config: %v", err)
+	}
+
+	if errs := c.Check(); len(errs) > 0 {
+		t.Errorf("errors in example config: %v", errs)
+	}
+
+	t.Logf("config: %v", c)
+}
+
 func TestCheck(t *testing.T) {
 	// routes must be set.
 	contents := `