fix(ci): use bundled table deep compares with busted

This commit is contained in:
Barrett Ruth 2025-09-19 14:08:17 -04:00
parent 1fbac30332
commit 259ab328a7
2 changed files with 14 additions and 5 deletions

View file

@ -7,7 +7,7 @@ local M = {}
---Convert test status to CP terminology with colors
---@param test_case TestCase
---@return StatusInfo
local function get_status_info(test_case)
function M.get_status_info(test_case)
if test_case.status == 'pass' then
return { text = 'AC', highlight_group = 'CpTestAC' }
elseif test_case.status == 'fail' then
@ -36,7 +36,7 @@ function M.render_test_list(test_state)
for i, test_case in ipairs(test_state.test_cases) do
local is_current = i == test_state.current_index
local prefix = is_current and '> ' or ' '
local status_info = get_status_info(test_case)
local status_info = M.get_status_info(test_case)
local status_text = status_info.text ~= '' and status_info.text or ''
local line = string.format('%s%d. %s', prefix, i, status_text)

View file

@ -4,7 +4,8 @@ describe('cp.diff', function()
describe('get_available_backends', function()
it('returns vim and git backends', function()
local backends = diff.get_available_backends()
assert.same({ 'vim', 'git' }, backends)
table.sort(backends)
assert.same({ 'git', 'vim' }, backends)
end)
end)
@ -30,7 +31,11 @@ describe('cp.diff', function()
describe('is_git_available', function()
it('returns true when git command succeeds', function()
local mock_system = stub(vim, 'system')
mock_system.returns({ code = 0 })
mock_system.returns({
wait = function()
return { code = 0 }
end,
})
local result = diff.is_git_available()
assert.is_true(result)
@ -40,7 +45,11 @@ describe('cp.diff', function()
it('returns false when git command fails', function()
local mock_system = stub(vim, 'system')
mock_system.returns({ code = 1 })
mock_system.returns({
wait = function()
return { code = 1 }
end,
})
local result = diff.is_git_available()
assert.is_false(result)