diff --git a/getpkg/test.sh b/getpkg/test.sh index 3741969..0ddb1e4 100755 --- a/getpkg/test.sh +++ b/getpkg/test.sh @@ -374,12 +374,6 @@ EOF PUBLISH_NOARCH_OUTPUT=$(timeout 3 "$GETPKG" publish "${TEST_TOOL_NOARCH}" "${TEST_DIR}/${TEST_TOOL_NOARCH}" 2>&1) || PUBLISH_NOARCH_OUTPUT="" if [[ "$PUBLISH_NOARCH_OUTPUT" =~ Published! ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ URL: ]] && [[ "$PUBLISH_NOARCH_OUTPUT" =~ Hash: ]]; then print_test_result "Publish tool without ARCH" 0 - # Clean up the noarch tool - NOARCH_HASH=$(curl -s "https://getpkg.xyz/hash/${TEST_TOOL_NOARCH}" 2>/dev/null || echo "") - if [ -n "$NOARCH_HASH" ] && [ "$NOARCH_HASH" != "null" ] && [ "$NOARCH_HASH" != "Not found" ]; then - curl -s -H "Authorization: Bearer ${SOS_WRITE_TOKEN}" \ - "https://getpkg.xyz/deleteobject?hash=${NOARCH_HASH}" >/dev/null 2>&1 || true - fi else print_test_result "Publish tool without ARCH" 1 fi @@ -388,20 +382,36 @@ EOF echo -e "\nTest 13c: Install universal tool (arch fallback)" rm -rf ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" ~/.getpkg/"${TEST_TOOL_NOARCH}" ~/.local/bin/getpkg/"${TEST_TOOL_NOARCH}" 2>/dev/null || true FALLBACK_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || FALLBACK_INSTALL_OUTPUT="" - if [[ "$FALLBACK_INSTALL_OUTPUT" =~ Arch-specific\ version\ not\ found,\ trying\ universal\ version ]] && [[ "$FALLBACK_INSTALL_OUTPUT" =~ Installed\ ${TEST_TOOL_NOARCH}\ successfully ]]; then - print_test_result "Install universal tool with arch fallback" 0 - - # Test update check for universal tool - UPDATE_UNIVERSAL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || UPDATE_UNIVERSAL_OUTPUT="" - if [[ "$UPDATE_UNIVERSAL_OUTPUT" =~ ${TEST_TOOL_NOARCH}\ is\ already\ up\ to\ date ]]; then - print_test_result "Update check for universal tool" 0 + + # Check if tool was installed successfully and has universal architecture + if [[ "$FALLBACK_INSTALL_OUTPUT" =~ Installed\ ${TEST_TOOL_NOARCH}\ successfully ]] && [ -f ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" ]; then + # Verify the architecture is "universal" in the config file + INSTALLED_ARCH=$(grep -o '"arch"[[:space:]]*:[[:space:]]*"[^"]*"' ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" | sed 's/.*"\([^"]*\)".*/\1/') + if [ "$INSTALLED_ARCH" = "universal" ]; then + print_test_result "Install universal tool with arch fallback" 0 + + # Test update check for universal tool + UPDATE_UNIVERSAL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || UPDATE_UNIVERSAL_OUTPUT="" + if [[ "$UPDATE_UNIVERSAL_OUTPUT" =~ ${TEST_TOOL_NOARCH}\ is\ already\ up\ to\ date ]]; then + print_test_result "Update check for universal tool" 0 + else + print_test_result "Update check for universal tool" 1 + fi else + print_test_result "Install universal tool with arch fallback" 1 print_test_result "Update check for universal tool" 1 fi else print_test_result "Install universal tool with arch fallback" 1 print_test_result "Update check for universal tool" 1 fi + + # Clean up the noarch tool from server + NOARCH_HASH=$(curl -s "https://getpkg.xyz/hash/${TEST_TOOL_NOARCH}" 2>/dev/null || echo "") + if [ -n "$NOARCH_HASH" ] && [ "$NOARCH_HASH" != "null" ] && [ "$NOARCH_HASH" != "Not found" ]; then + curl -s -H "Authorization: Bearer ${SOS_WRITE_TOKEN}" \ + "https://getpkg.xyz/deleteobject?hash=${NOARCH_HASH}" >/dev/null 2>&1 || true + fi else echo -e "\n${YELLOW}Skipping publish/install tests (SOS_WRITE_TOKEN not set)${NC}" echo "To run full tests, set SOS_WRITE_TOKEN environment variable"