Skip to content

Commit

Permalink
fixup! Tests to validate continuous queues manager release date setting
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Mar 12, 2024
1 parent 6632f5a commit f9e77fc
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions tests/3-continuous_manage_queues_validation.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,59 @@ load libs/shared_setup
setup () {
export WORKSPACE=$gitdir

# Some dummy variables just for the sake of the tests.
# Some dummy variables just for the sake of the letting the script proceed through the validation.
export jiraclicmd=jiracli
export jiraserver=https://tracker.moodle.org
export jirauser=jirauser
export jirapass=jirapass

# Just do a dry run. Because if the test tries to actually connect to the server it will fail.
# But we'll confirm validation succeeds when the dry run message comes up.
export dryrun=1
ci_run source tracker_automations/continuous_manage_queues/lib.sh
}

@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date < release date" {
export releasedate=$(date -d "+10day" +%Y-%m-%d)
ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh
releasedate=$(date -d "+10day" +%Y-%m-%d)

run_param_validation $releasedate

# Assert result.
assert_output --partial "Dry-run enabled, no changes will be performed to the tracker"
assert_output --partial "Parameters validated."
}

@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date = on-sync date" {
export releasedate=$(date -d "-28day" +%Y-%m-%d)
ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh
releasedate=$(date -d "-28day" +%Y-%m-%d)

run_param_validation $releasedate

# Assert result.
assert_output --partial "Dry-run enabled, no changes will be performed to the tracker"
assert_output --partial "Parameters validated."
}

@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date > on-sync date" {
export releasedate=$(date -d "-29day" +%Y-%m-%d)
ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh
releasedate=$(date -d "-29day" +%Y-%m-%d)

run_param_validation $releasedate

# Assert result.
assert_failure
assert_output --partial "ERROR: The current date is already past the on-sync period. Please make sure the Release date (${releasedate}) is configured correctly."
}

@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Invalid release date format" {
export releasedate=$(date +%m-%d-%Y)
export lastweekdate=$(date +%Y-%m-%d)
ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh
releasedate=$(date +%m-%d-%Y)
lastweekdate=$(date +%Y-%m-%d)

run_param_validation $releasedate $lastweekdate

# Assert result.
assert_failure
assert_output --partial "ERROR: \$releasedate. Incorrect YYYY-MM-DD format detected: ${releasedate}"
}

@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Invalid last week date format" {
export releasedate=$(date -d "+7day" +%Y-%m-%d)
export lastweekdate=$(date +%m-%d-%Y)
ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh
releasedate=$(date -d "+7day" +%Y-%m-%d)
lastweekdate=$(date +%m-%d-%Y)

run_param_validation $releasedate $lastweekdate

# Assert result.
assert_failure
Expand Down

0 comments on commit f9e77fc

Please sign in to comment.