From 7d26aa60349e72c3d437d329a678a51331914233 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 29 Jul 2026 20:56:46 +0200 Subject: test(cli): isolate the suite from the real ~/.config/lectio The ref/rand cli tests assume English book abbreviations ("Jn 3:16"), but with no LECTIO_CONFIG set they read the developer's real user config. On a machine whose config has ui_language = pl (sigla_style = auto -> Polish dialect), "Jn" is not a valid abbreviation and TestRefSingle, TestRefEnglishDialect, TestRefRejectsPolishAbbrevInEnglish, TestRefCompare and TestRandVerse fail -- while passing on a clean CI. Add a package TestMain that points LECTIO_CONFIG at a throwaway temp path, forcing built-in defaults for every cli test and guaranteeing the suite never reads or writes the real user config. Suite now green on a Polish config too. --- internal/cli/main_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 internal/cli/main_test.go (limited to 'internal/cli/main_test.go') diff --git a/internal/cli/main_test.go b/internal/cli/main_test.go new file mode 100644 index 0000000..62989e5 --- /dev/null +++ b/internal/cli/main_test.go @@ -0,0 +1,26 @@ +package cli + +import ( + "os" + "path/filepath" + "testing" +) + +// TestMain isolates the cli test suite from the developer's real +// ~/.config/lectio. Several reference/random tests assume English book +// abbreviations (e.g. "Jn 3:16"); a user config with ui_language = pl makes +// sigla_style = auto resolve to the Polish dialect, where "Jn" is not a valid +// abbreviation, so those tests fail on such a developer's machine even though +// they pass on a clean CI. Pointing LECTIO_CONFIG at a throwaway, +// non-existent path forces the built-in defaults for every cli test and keeps +// the suite from ever reading -- or writing -- the real user config. +func TestMain(m *testing.M) { + dir, err := os.MkdirTemp("", "lectio-cli-test") + if err != nil { + panic(err) + } + os.Setenv("LECTIO_CONFIG", filepath.Join(dir, "config.ini")) + code := m.Run() + os.RemoveAll(dir) + os.Exit(code) +} -- cgit v1.3