From f2c7efdd6fd735eff9acd04163afb9d477cf3f3c Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 6 Mar 2026 15:43:55 -0500 Subject: [PATCH] test(oauth): isolate bundled-credentials fallback from real filesystem Problem: `resolve_credentials` reads from `vim.fn.stdpath('data')`, the real Neovim data dir. The test passed only because `_wipe()` was incidentally deleting the user's credential file mid-run. Solution: stub `oauth.load_json_file` for the duration of the test so real credential files cannot interfere with the fallback assertion. --- spec/oauth_spec.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/oauth_spec.lua b/spec/oauth_spec.lua index 520227d..caf857a 100644 --- a/spec/oauth_spec.lua +++ b/spec/oauth_spec.lua @@ -142,8 +142,11 @@ describe('oauth', function() it('falls back to bundled credentials', function() config.reset() vim.g.pending = { data_path = tmpdir .. '/tasks.json' } + local orig_load = oauth.load_json_file + oauth.load_json_file = function() return nil end local c = oauth.new({ name = 'gtasks', scope = 'x', port = 0, config_key = 'gtasks' }) local creds = c:resolve_credentials() + oauth.load_json_file = orig_load assert.equals(oauth._BUNDLED_CLIENT_ID, creds.client_id) assert.equals(oauth._BUNDLED_CLIENT_SECRET, creds.client_secret) end)