Files
abrown38andClaude Opus 5.5 3c0808591f Steward 0.1.0 (in development): a DHCPv4 server with a web UI, API and CLI
Subnets served per interface, pools, reservations, options at three
levels, leases in SQLite saved before the ACK, ping and decline conflict
checks, validated changes with history and undo, users and tokens, an
audit log, a Kea importer, a sandboxed systemd unit and Debian packages.
Tested with real udhcpc and dhcpcd clients in Docker (scripts/e2e.sh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:14:07 +01:00

43 lines
1.1 KiB
Go

package config
import (
"os"
"path/filepath"
"reflect"
"strings"
"testing"
)
func TestExampleIsTheDefaults(t *testing.T) {
path := filepath.Join(t.TempDir(), "steward.yaml")
os.WriteFile(path, []byte(Example), 0o644)
c, err := Load(path, false)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(c, Default()) {
t.Errorf("example differs from the defaults:\n%+v\n%+v", c, Default())
}
}
func TestErrors(t *testing.T) {
cases := map[string]string{
"listen: []": "listen",
"database: relative.db": "database",
"session: {cookie_secure: x}": "cookie_secure",
"tls: {cert_file: /a}": "tls",
"no_such_setting: 1": "no_such_setting",
"backup: {retention: 3x}": "duration",
}
for yml, want := range cases {
path := filepath.Join(t.TempDir(), "s.yaml")
os.WriteFile(path, []byte(yml), 0o644)
if _, err := Load(path, false); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%q: %v", yml, err)
}
}
if _, err := Load("/nonexistent/steward.yaml", true); err != nil {
t.Errorf("missing file allowed: %v", err)
}
}