When implementing network functionality, consolidate around standardized APIs like `vim.net.request()` instead of maintaining custom download functions or direct curl calls. Implement comprehensive testing for network operations using integration test guards to prevent failures in environments without network access.
When implementing network functionality, consolidate around standardized APIs like vim.net.request()
instead of maintaining custom download functions or direct curl calls. Implement comprehensive testing for network operations using integration test guards to prevent failures in environments without network access.
Key practices:
vim.net.request()
NVIM_TEST_INTEG
)t.skip()
to conditionally skip network tests when integration testing is disabledExample implementation:
-- Instead of custom download functions
local function download(url)
-- Replace with vim.net.request()
end
-- Proper test guarding
describe('network functionality', function()
local skip_integ = os.getenv('NVIM_TEST_INTEG') ~= '1'
it('handles text responses', function()
if skip_integ then t.skip() end
-- network test implementation
end)
it('handles binary responses', function()
if skip_integ then t.skip() end
-- binary response test
end)
end)
This approach ensures consistent network handling across the codebase while maintaining testability in various environments.
Enter the URL of a public GitHub repository