spiegel/internal/config/toml_test.go

53 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-04-04 01:12:42 +02:00
package config_test
import (
"testing"
2024-04-08 03:56:21 +02:00
"git.gnous.eu/ada/spiegel/internal/config"
2024-04-04 01:12:42 +02:00
)
func TestToml(t *testing.T) {
t.Parallel()
testLoadTomlValid(t)
}
func testLoadTomlValid(t *testing.T) {
t.Helper()
got, err := config.LoadToml("test_resources/valid.toml")
if err != nil {
t.Fatal("Cannot load config: ", err)
}
2024-04-04 01:12:42 +02:00
if got.CloneDirectory != "archive/" {
t.Fatal("Invalid CloneDirectory: ", got.CloneDirectory)
}
if got.Interval != 10 {
t.Fatal("Invalid Interval: ", got.Interval)
}
2024-04-04 01:12:42 +02:00
if got.Log.Level != "WARN" {
t.Fatal("Invalid log level: ", got.Log.Level)
}
if got.Log.File != "log.txt" {
t.Fatal("Invalid log file: ", got.Log.File)
}
if got.RepoList[0].Name != "linux" {
t.Fatal("Invalid first repo name: ", got.RepoList[0].Name)
}
if got.RepoList[0].URL != "https://github.com/torvalds/linux/" {
t.Fatal("Invalid first repo url: ", got.RepoList[0].URL)
}
if got.RepoList[1].Name != "linuxtwo" {
t.Fatal("Invalid second repo name: ", got.RepoList[1].Name)
}
if got.RepoList[1].URL != "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" {
t.Fatal("Invalid second repo URL: ", got.RepoList[1].URL)
}
}