From 4f9de809f81122307f72780fe450738e4f481ca7 Mon Sep 17 00:00:00 2001 From: chblodg Date: Sun, 5 Jun 2022 13:16:12 -0700 Subject: [PATCH] updating forgeapi tests and adding is false (#1548) Co-authored-by: christopher blodgett --- scripts/start-setupForgeApiMods | 7 +++--- scripts/start-utils | 22 +++++++++++++++++++ ...ompose.yml.disabled => docker-compose.yml} | 1 + .../forgeapimods_file/forgeapi_mods.json | 20 ++++++++--------- .../forgeapimods_file/verify.sh | 4 ++-- ...ompose.yml.disabled => docker-compose.yml} | 7 +++--- .../forgeapimods_gametype/verify.sh | 6 ++--- ...ompose.yml.disabled => docker-compose.yml} | 0 8 files changed, 46 insertions(+), 21 deletions(-) rename tests/setuponlytests/forgeapimods_file/{docker-compose.yml.disabled => docker-compose.yml} (97%) rename tests/setuponlytests/forgeapimods_gametype/{docker-compose.yml.disabled => docker-compose.yml} (84%) rename tests/setuponlytests/forgeapimods_projectids/{docker-compose.yml.disabled => docker-compose.yml} (100%) diff --git a/scripts/start-setupForgeApiMods b/scripts/start-setupForgeApiMods index a0b899cc..91b12f29 100644 --- a/scripts/start-setupForgeApiMods +++ b/scripts/start-setupForgeApiMods @@ -118,7 +118,7 @@ modFileByProjectID(){ # Looks for file by name current_project_file=$(jq -n "$project_files" | jq --arg FILE_NAME "$project_id_file_name" -jc ' .data | map(select(.fileName<=($FILE_NAME))) | .[0] // empty') - elif $( ! isTrue "$MODS_FORGEAPI_IGNORE_GAMETYPE" ) && $FILTER_BY_FAMILY ; then + elif isFalse "${MODS_FORGEAPI_IGNORE_GAMETYPE}" && $FILTER_BY_FAMILY ; then # Looks for file by version and server type in lowercase current_project_file=$(jq -n "$project_files" | jq --arg RELEASE_FILTER "$RELEASE_NUMBER_FILTER" --arg GAME_TYPE "${FAMILY,,}" --arg VERSION "$VANILLA_VERSION" -jc ' .data | sort_by(.id) | reverse | map(select(.gameVersions[] | ascii_downcase | contains ($GAME_TYPE))) | map(select(.gameVersions[] | contains ($VERSION))) | map(select(.releaseType<=($RELEASE_FILTER|tonumber))) | .[0] // empty') @@ -160,7 +160,7 @@ downloadModPackfromModFile() { fi # trys to make the output directory incase it doesnt exist. mkdir -p "$out_dir" - + debug "DEBUG: PROJECT_FILE: ${PROJECT_FILE}" # grabs needed values from our json return file_name=$(jq -n "$PROJECT_FILE" | jq -jc '.fileName // empty' ) download_url=$(jq -n "$PROJECT_FILE" | jq -jc '.downloadUrl // empty' ) @@ -204,9 +204,10 @@ if [ "$MODS_FORGEAPI_FILE" ] && [ -z "$MODS_FORGEAPI_PROJECTIDS" ]; then log "ERROR: given MODS_FORGEAPI_FILE file does not exist" exit 2 fi - + debug "DEBUG: MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_FILE}" # Needs loop here to look up release types befor calling download. while read -r current_project; do + debug "DEBUG: current_project: ${current_project}" # Per stack overflow we can use //empty to return empty string that works with -z project_id=$(jq -n "$current_project" | jq -r '.projectId // empty' ) current_release_type=$(jq -n "$current_project" | jq -r '.releaseType // empty' ) diff --git a/scripts/start-utils b/scripts/start-utils index fe0e2780..efc33aca 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -66,6 +66,28 @@ function isTrue() { return ${result} } +function isFalse() { + local oldState + oldState=$(shopt -po xtrace) + shopt -u -o xtrace + + local value=${1,,} + + result= + + case ${value} in + false | off) + result=0 + ;; + *) + result=1 + ;; + esac + + eval "$oldState" + return ${result} +} + function isDebugging() { if isTrue "${DEBUG:-false}"; then return 0 diff --git a/tests/setuponlytests/forgeapimods_file/docker-compose.yml.disabled b/tests/setuponlytests/forgeapimods_file/docker-compose.yml similarity index 97% rename from tests/setuponlytests/forgeapimods_file/docker-compose.yml.disabled rename to tests/setuponlytests/forgeapimods_file/docker-compose.yml index 9dae2ebd..9e1959b4 100644 --- a/tests/setuponlytests/forgeapimods_file/docker-compose.yml.disabled +++ b/tests/setuponlytests/forgeapimods_file/docker-compose.yml @@ -7,6 +7,7 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" + DEBUG: "FALSE" # Using custom to bypass Fabric setup TYPE: CUSTOM # Using family to test FORGEAPI Family filter. diff --git a/tests/setuponlytests/forgeapimods_file/forgeapi_mods.json b/tests/setuponlytests/forgeapimods_file/forgeapi_mods.json index 01a20e31..bd005e70 100644 --- a/tests/setuponlytests/forgeapimods_file/forgeapi_mods.json +++ b/tests/setuponlytests/forgeapimods_file/forgeapi_mods.json @@ -1,11 +1,11 @@ -[{ - "name": "On A Stick [FABRIC]", - "projectId": "550544", - "releaseType": "release" - }, - { - "name": "Fabric Voice Mod", - "projectId": "416089", - "releaseType": "beta" - } +[ + { + "name": "Flan (Land Claim Tool)", + "projectId": "404578" + }, + { + "name": "Fabric Voice Mod", + "projectId": "416089", + "releaseType": "beta" + } ] diff --git a/tests/setuponlytests/forgeapimods_file/verify.sh b/tests/setuponlytests/forgeapimods_file/verify.sh index c0a98132..145e4335 100644 --- a/tests/setuponlytests/forgeapimods_file/verify.sh +++ b/tests/setuponlytests/forgeapimods_file/verify.sh @@ -1,5 +1,5 @@ # Validates specific beta call out for specific mod: mc-image-helper assert fileExists "/data/mods/voicechat-fabric*" -mc-image-helper assert fileExists "/data/mods/onastick-fabric*" -# Dependent of on a stick: +mc-image-helper assert fileExists "/data/mods/flan*" +# Dependent of flan: mc-image-helper assert fileExists "/data/mods/fabric-api*" diff --git a/tests/setuponlytests/forgeapimods_gametype/docker-compose.yml.disabled b/tests/setuponlytests/forgeapimods_gametype/docker-compose.yml similarity index 84% rename from tests/setuponlytests/forgeapimods_gametype/docker-compose.yml.disabled rename to tests/setuponlytests/forgeapimods_gametype/docker-compose.yml index 7a9bc503..c14140f0 100644 --- a/tests/setuponlytests/forgeapimods_gametype/docker-compose.yml.disabled +++ b/tests/setuponlytests/forgeapimods_gametype/docker-compose.yml @@ -7,6 +7,7 @@ services: environment: EULA: "TRUE" SETUP_ONLY: "TRUE" + DEBUG: "FALSE" # Using custom to bypass Fabric setup TYPE: CUSTOM # Using family to test FORGEAPI Family filter. @@ -17,13 +18,13 @@ services: MODS_FORGEAPI_IGNORE_GAMETYPE: "TRUE" # Validates that Biomes does not download terrablender # Using default false for testing: - # MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES: "FALSE" + MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES: "FALSE" # Contains mix of Forge and Fabric mods - MODS_FORGEAPI_PROJECTIDS: 306612,416089,220318 + MODS_FORGEAPI_PROJECTIDS: 416089,493246 # Allows for Beta releases of 416089 the Fabric Voice Mod MODS_FORGEAPI_RELEASES: BETA MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_KEY} - REMOVE_OLD_FORGEAPI_MODS: "FALSE" + REMOVE_OLD_FORGEAPI_MODS: "TRUE" volumes: - ./data:/data - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/forgeapimods_gametype/verify.sh b/tests/setuponlytests/forgeapimods_gametype/verify.sh index 98e788a7..ecb1d00d 100644 --- a/tests/setuponlytests/forgeapimods_gametype/verify.sh +++ b/tests/setuponlytests/forgeapimods_gametype/verify.sh @@ -1,5 +1,5 @@ -mc-image-helper assert fileExists "/data/mods/BiomesOPlenty*" # testing dependencies don't get downloaded when download dependencies is set to false. -! mc-image-helper assert fileExists "/data/mods/TerraBlender*" mc-image-helper assert fileExists "/data/mods/voicechat-fabric*" -mc-image-helper assert fileExists "/data/mods/fabric-api*" +mc-image-helper assert fileExists "/data/mods/flan*" +# Dependent of flan, but dependencies are set to false: +! mc-image-helper assert fileExists "/data/mods/fabric-api*" diff --git a/tests/setuponlytests/forgeapimods_projectids/docker-compose.yml.disabled b/tests/setuponlytests/forgeapimods_projectids/docker-compose.yml similarity index 100% rename from tests/setuponlytests/forgeapimods_projectids/docker-compose.yml.disabled rename to tests/setuponlytests/forgeapimods_projectids/docker-compose.yml