Basic config package to parse NTP Pool system config

This commit is contained in:
2023-12-10 20:43:38 -08:00
parent 608f05d395
commit 5c7ae6ab8a
3 changed files with 147 additions and 0 deletions

26
config/config_test.go Normal file
View File

@@ -0,0 +1,26 @@
package config
import (
"net/url"
"os"
"testing"
)
func TestBaseURL(t *testing.T) {
os.Setenv("web_hostname", "www.ntp.dev, web.ntppool.dev")
os.Setenv("web_tls", "yes")
c := New()
if !c.Valid() {
t.Fatalf("config not valid")
}
q := url.Values{}
q.Set("foo", "bar")
u := c.WebURL("/foo", &q)
if u != "https://www.ntp.dev/foo?foo=bar" {
t.Fatalf("unexpected WebURL: %s", u)
}
}