2020-10-27 17:17:41 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2022-08-21 20:30:07 +02:00
|
|
|
func assertEqual[S comparable](have S, want S, t *testing.T) {
|
2020-10-27 17:17:41 +01:00
|
|
|
if have != want {
|
2022-08-21 20:30:07 +02:00
|
|
|
t.Error("have:", have, ", want:", want, "\n")
|
2020-10-27 17:17:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfigFromFile(t *testing.T) {
|
|
|
|
config, err := ConfigFromFile("example.conf")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2022-08-21 20:30:07 +02:00
|
|
|
assertEqual(config.Port, 4711, t)
|
|
|
|
assertEqual(config.LinkPrefix, "https://jaf.example.com/", t)
|
|
|
|
assertEqual(config.FileDir, "/var/www/jaf/", t)
|
|
|
|
assertEqual(config.LinkLength, 5, t)
|
2020-10-27 17:17:41 +01:00
|
|
|
}
|