From 175aa1343ff04383a5a1a8ba166505933d9be46a Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 28 Jul 2026 21:39:49 +0200 Subject: config: drop go-toml and the legacy TOML migrations The one-shot config.toml -> config.ini and books.toml -> books.ini migrations (a transition aid from the pre-INI format) are removed, along with the github.com/pelletier/go-toml/v2 dependency and the now-dead `toml:` struct tags. The live config format has been INI for many releases; anyone still on a .toml recreates it (the format is self-documenting on first run). Leaves 3 direct deps, all in active use (bubbletea, lipgloss, go-pdf/fpdf). Tests updated to write INI. --- internal/config/config_test.go | 46 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) (limited to 'internal/config/config_test.go') diff --git a/internal/config/config_test.go b/internal/config/config_test.go index dd75808..4d172c0 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -68,8 +68,8 @@ func TestLoadOverride(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("offline = true\ndefault_version = \"wuj\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("offline = true\ndefault_version = wuj\n"), 0o644) cfg, _ := Load() if !cfg.Offline || cfg.DefaultVersion != "wuj" { t.Errorf("override not applied: %+v", cfg) @@ -121,8 +121,8 @@ func TestWebDisplayLoadsSetting(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("web_display = \"vertical\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("web_display = vertical\n"), 0o644) cfg, err := Load() if err != nil { t.Fatal(err) @@ -136,8 +136,8 @@ func TestWebDisplayNormalizesUnknown(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("web_display = \"bogus\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("web_display = bogus\n"), 0o644) cfg, err := Load() if err != nil { t.Fatal(err) @@ -158,8 +158,8 @@ func TestUILanguageLoadsPL(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("ui_language = \"pl\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("ui_language = pl\n"), 0o644) cfg, err := Load() if err != nil { t.Fatal(err) @@ -176,8 +176,8 @@ func TestUILanguagePreservesAnyCode(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("ui_language = \"FR\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("ui_language = FR\n"), 0o644) cfg, err := Load() if err != nil { t.Fatal(err) @@ -210,8 +210,8 @@ func TestPagerLoadsSetting(t *testing.T) { dir := t.TempDir() t.Setenv("XDG_CONFIG_HOME", dir) os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("pager = \"less -R\"\n"), 0o644) + os.WriteFile(filepath.Join(dir, "lectio", "config.ini"), + []byte("pager = less -R\n"), 0o644) cfg, err := Load() if err != nil { t.Fatal(err) @@ -303,28 +303,6 @@ func TestUseLayers(t *testing.T) { } } -func TestMigrateTOMLToINI(t *testing.T) { - dir := t.TempDir() - t.Setenv("XDG_CONFIG_HOME", dir) - os.MkdirAll(filepath.Join(dir, "lectio"), 0o755) - // only the old TOML exists -> Load converts once and writes config.ini. - os.WriteFile(filepath.Join(dir, "lectio", "config.toml"), - []byte("ui_language = \"pl\"\ndefault_version = \"wuj\"\n"), 0o644) - cfg, err := Load() - if err != nil { - t.Fatal(err) - } - if cfg.UILanguage != "pl" || cfg.DefaultVersion != "wuj" { - t.Errorf("migrated values wrong: %+v", cfg) - } - if _, err := os.Stat(filepath.Join(dir, "lectio", "config.ini")); err != nil { - t.Error("config.ini not written on migration") - } - if _, err := os.Stat(filepath.Join(dir, "lectio", "config.toml")); err != nil { - t.Error("old config.toml should be kept (reversible)") - } -} - func TestPartShown(t *testing.T) { var empty Config if !empty.PartShown("new", "psalm") { -- cgit v1.3