From 101062cb48b2b7fd4b505ac773aa56c3ac90faec Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 22 Sep 2025 20:24:56 -0400 Subject: [PATCH] fix(test): clear modules properly --- spec/error_boundaries_spec.lua | 14 ++++++++++---- spec/highlight_spec.lua | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/error_boundaries_spec.lua b/spec/error_boundaries_spec.lua index 5b583bd..9c711fb 100644 --- a/spec/error_boundaries_spec.lua +++ b/spec/error_boundaries_spec.lua @@ -31,6 +31,12 @@ describe('Error boundary handling', function() } end, scrape_contest_metadata = function(_, contest_id) + if contest_id == 'fail_scrape' then + return { + success = false, + error = 'Network error', + } + end if contest_id == 'fail_metadata' then return { success = false, @@ -122,14 +128,14 @@ describe('Error boundary handling', function() it('should handle scraping failures without state corruption', function() cp.handle_command({ fargs = { 'codeforces', 'fail_scrape', 'a' } }) - local has_error = false + local has_metadata_error = false for _, log_entry in ipairs(logged_messages) do - if log_entry.level == vim.log.levels.ERROR then - has_error = true + if log_entry.msg and log_entry.msg:match('failed to load contest metadata') then + has_metadata_error = true break end end - assert.is_true(has_error, 'Should log error for failed scraping') + assert.is_true(has_metadata_error, 'Should log contest metadata failure') local context = cp.get_current_context() assert.equals('codeforces', context.platform) diff --git a/spec/highlight_spec.lua b/spec/highlight_spec.lua index 67fcd6c..8897cc4 100644 --- a/spec/highlight_spec.lua +++ b/spec/highlight_spec.lua @@ -68,6 +68,7 @@ index 1234567..abcdefg 100644 end) it('handles valid highlight data without errors', function() + vim.api.nvim_buf_set_lines(1, 0, -1, false, { 'hello world test line' }) local highlights = { { line = 0,