From a2c25031bb1d0aa56eba3a04891961e1347688b0 Mon Sep 17 00:00:00 2001 From: kiran94 Date: Thu, 27 Apr 2023 22:29:39 +0100 Subject: [PATCH 1/2] fix(ci): ensure tests do not hang --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index ebd77d5..a70450d 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ run: nvim --cmd "set rtp+=./" --cmd 'lua require("s3edit").setup()' -o lua/s3edit/init.lua test: - nvim --cmd "set rtp+=./" --headless -c "PlenaryBustedDirectory lua/tests/ { minimal_init = 'lua/tests/setup.vim' }" + nvim --cmd "set rtp+=./" --headless -c "PlenaryBustedDirectory lua/tests/" help: nvim --cmd "set rtp+=./" --cmd 'h s3edit' From badd2b2bc160940c7db0e7039cd72f3236759448 Mon Sep 17 00:00:00 2001 From: kiran94 Date: Thu, 27 Apr 2023 22:52:47 +0100 Subject: [PATCH 2/2] fix(s3): ensure api operations always use json --- lua/s3edit/s3.lua | 4 ++-- lua/tests/s3_spec.lua | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/s3edit/s3.lua b/lua/s3edit/s3.lua index 2df187a..d7faecd 100644 --- a/lua/s3edit/s3.lua +++ b/lua/s3edit/s3.lua @@ -4,7 +4,7 @@ local sys = require("s3edit.system") --- Gets the Bucket Names from S3 ---@return table a list of bucket names M.get_bucket_names = function() - local result = sys.make_system_call("aws s3api list-buckets") + local result = sys.make_system_call("aws s3api list-buckets --output json") if result == nil then return {} end @@ -23,7 +23,7 @@ end ---@param bucket string the bucket to search ---@return table a list of objects M.get_objects = function(bucket) - local result = sys.make_system_call("aws s3api list-objects --bucket " .. bucket) + local result = sys.make_system_call("aws s3api list-objects --bucket " .. bucket .. " --output json") if result == nil then return {} end diff --git a/lua/tests/s3_spec.lua b/lua/tests/s3_spec.lua index bb9631c..b94b0a8 100644 --- a/lua/tests/s3_spec.lua +++ b/lua/tests/s3_spec.lua @@ -10,7 +10,7 @@ describe("get_bucket_names", function() local result = s3.get_bucket_names() assert.are.same({}, result) - assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-buckets") + assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-buckets --output json") end) it("should parse the bucket names", function() @@ -39,7 +39,7 @@ describe("get_bucket_names", function() assert.are.same("bucket1", result[1]) assert.are.same("bucket2", result[2]) - assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-buckets") + assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-buckets --output json") end) end) @@ -51,7 +51,7 @@ describe("get_objects", function() local result = s3.get_objects("my_bucket") assert.are.same({}, result) - assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket") + assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket --output json") end) it("should parse the objects", function() @@ -89,7 +89,7 @@ describe("get_objects", function() assert.are.same("key1", result[1]) assert.are.same("path/key2", result[2]) - assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket") + assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket --output json") end) it("should return empty when no objects are found", function() @@ -101,7 +101,7 @@ describe("get_objects", function() local result = s3.get_objects("my_bucket") assert.are.same({}, result) - assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket") + assert.stub(mock_sys.make_system_call).was_called_with("aws s3api list-objects --bucket my_bucket --output json") end) end)