aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go46
1 files changed, 12 insertions, 34 deletions
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") {