From 7b5d616eaddaee5fa8f73dea9a6593b27c06248e Mon Sep 17 00:00:00 2001 From: "Anderson A. Giacomolli" Date: Fri, 6 Nov 2026 14:19:36 -0300 Subject: [PATCH] Name the fields of the config test cases The test cases of the configuration and the data directory set their fields by name, with one field on each line, as the go-code skill requires. A case then shows which value is the XDG directory and which is the home directory without a look at the struct. A search of the rest of the code finds no other positional struct literal. The node keys stay positional, because the skill allows a small two-field type that acts as one value. Issue: b14d537 --- config_test.go | 62 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/config_test.go b/config_test.go index ae84c96..4dcf94e 100644 --- a/config_test.go +++ b/config_test.go @@ -36,12 +36,30 @@ func TestLoadConfigRejectsInvalidFiles(t *testing.T) { name string text string }{ - {"unknown field", `{"endpont": "api"}`}, - {"unknown nested field", `{"compactor": {"modle": "x"}}`}, - {"endpoint URL", `{"endpoint": "https://example.com/v1/responses"}`}, - {"empty model", `{"compactor": {"model": ""}}`}, - {"second object", `{} {}`}, - {"broken JSON", `{"endpoint": `}, + { + name: "unknown field", + text: `{"endpont": "api"}`, + }, + { + name: "unknown nested field", + text: `{"compactor": {"modle": "x"}}`, + }, + { + name: "endpoint URL", + text: `{"endpoint": "https://example.com/v1/responses"}`, + }, + { + name: "empty model", + text: `{"compactor": {"model": ""}}`, + }, + { + name: "second object", + text: `{} {}`, + }, + { + name: "broken JSON", + text: `{"endpoint": `, + }, } for _, tc := range testCases { @@ -64,10 +82,34 @@ func TestDataDirFollowsTheOrder(t *testing.T) { home string want string }{ - {"ONECHAT_DIR first", filepath.Join(root, "a"), filepath.Join(root, "xdg"), root, filepath.Join(root, "a")}, - {"absolute XDG_DATA_HOME", "", filepath.Join(root, "xdg"), root, filepath.Join(root, "xdg", "onechat")}, - {"relative XDG_DATA_HOME ignored", "", "xdg", root, filepath.Join(root, ".local", "share", "onechat")}, - {"home directory last", "", "", root, filepath.Join(root, ".local", "share", "onechat")}, + { + name: "ONECHAT_DIR first", + dir: filepath.Join(root, "a"), + xdg: filepath.Join(root, "xdg"), + home: root, + want: filepath.Join(root, "a"), + }, + { + name: "absolute XDG_DATA_HOME", + dir: "", + xdg: filepath.Join(root, "xdg"), + home: root, + want: filepath.Join(root, "xdg", "onechat"), + }, + { + name: "relative XDG_DATA_HOME ignored", + dir: "", + xdg: "xdg", + home: root, + want: filepath.Join(root, ".local", "share", "onechat"), + }, + { + name: "home directory last", + dir: "", + xdg: "", + home: root, + want: filepath.Join(root, ".local", "share", "onechat"), + }, } for _, tc := range testCases { -- 2.53.0