X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/8e8da466ded3b39188862e4b46f40220d65f316e..1e0b100b2d3d4af9f65daae7ede647ac9c388157:/config_test.go 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 {