This commit is contained in:
2026-09-05 10:00:36 +07:00
parent 25ca9b96a2
commit 9ad732c436
8 changed files with 319 additions and 24 deletions
+11 -13
View File
@@ -2,8 +2,6 @@ using Test
using GeneralUtils
using GeneralUtils.garageS3
using AWS
using Random: randstring
using UUIDs: uuid4
using URIs
@testset "garageS3.jl" begin
@@ -143,7 +141,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-$(randstring(8)).json"
test_key = "testrunner-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"status\": \"testing\", \"runner\": \"runtests\"}"
# Test put_file(storage, key, data) - successful upload
@@ -166,7 +164,7 @@ using URIs
@test test_key in keys
# Test put_file callable struct
test_key2 = "testrunner-callable-$(randstring(8)).json"
test_key2 = "testrunner-callable-$(GeneralUtils.uuid4snakecase()).json"
callable_result = put_file(storage)(test_key2, "callable-data")
@test callable_result !== nothing
@test callable_result.api != ""
@@ -195,7 +193,7 @@ using URIs
"testbucket"
)
test_key = "single/slash/test-$(randstring(8)).json"
test_key = "single/slash/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"level\": 1, \"nested\": true}"
# Upload nested key
@@ -228,7 +226,7 @@ using URIs
"testbucket"
)
test_key = "deep/nested/folder/subfolder/test-$(randstring(8)).json"
test_key = "deep/nested/folder/subfolder/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"deeply\": \"nested\", \"path\": \"deep/nested/folder/subfolder/\"}"
# Upload deeply nested key
@@ -260,7 +258,7 @@ using URIs
"testbucket"
)
test_key = "callable/nested/test-$(randstring(8)).json"
test_key = "callable/nested/test-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"callable\": true, \"nested\": true}"
uploader = put_file(storage)
@@ -282,7 +280,7 @@ using URIs
"a2c6b1379c2f731d3e6e5a408dd4d6cffca7511717675f55114ff94828febca1",
"testbucket"
)
result = get_file(storage, "nonexistent-key-$(randstring(8)).json")
result = get_file(storage, "nonexistent-key-$(GeneralUtils.uuid4snakecase()).json")
@test result === nothing
end
@@ -294,7 +292,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-binary-$(randstring(8)).bin"
test_key = "testrunner-binary-$(GeneralUtils.uuid4snakecase()).bin"
binary_data = UInt8[0x00, 0x01, 0x02, 0xFF, 0xFE, 0xFD, 0x48, 0x65, 0x6c, 0x6c, 0x6f]
result = put_file(storage, test_key, binary_data)
@@ -315,7 +313,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-list-$(randstring(8)).txt"
test_key = "testrunner-list-$(GeneralUtils.uuid4snakecase()).txt"
put_file(storage, test_key, "list-test-data")
keys = list_files(storage)
@@ -333,7 +331,7 @@ using URIs
"testbucket"
)
test_key = "testrunner-url-$(randstring(8)).json"
test_key = "testrunner-url-$(GeneralUtils.uuid4snakecase()).json"
result = put_file(storage, test_key, "url-test")
@test startswith(result.api, "https://s3-api.yiem.cc/testbucket/")
@@ -576,8 +574,8 @@ using URIs
"testbucket"
)
test_key = "testrunner-presign-$(randstring(8)).json"
test_data = "{\"presign\": true, \"test\": \"$(randstring(12))\"}"
test_key = "testrunner-presign-$(GeneralUtils.uuid4snakecase()).json"
test_data = "{\"presign\": true, \"test\": \"$(GeneralUtils.uuid4snakecase())\"}"
put_file(storage, test_key, test_data)
url = s3_sign_url(storage, test_key, 300)