|
| 1 | +#!/usr/bin/env bats |
| 2 | + |
| 3 | +load libs/shared_setup |
| 4 | + |
| 5 | +setup () { |
| 6 | + export WORKSPACE=$gitdir |
| 7 | + |
| 8 | + # Some dummy variables just for the sake of the tests. |
| 9 | + export jiraclicmd=jiracli |
| 10 | + export jiraserver=https://tracker.moodle.org |
| 11 | + export jirauser=jirauser |
| 12 | + export jirapass=jirapass |
| 13 | + |
| 14 | + # Just do a dry run. Because if the test tries to actually connect to the server it will fail. |
| 15 | + # But we'll confirm validation succeeds when the dry run message comes up. |
| 16 | + export dryrun=1 |
| 17 | +} |
| 18 | + |
| 19 | +@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date < release date" { |
| 20 | + export releasedate=$(date -d "+10day" +%Y-%m-%d) |
| 21 | + ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh |
| 22 | + |
| 23 | + # Assert result. |
| 24 | + assert_output --partial "Dry-run enabled, no changes will be performed to the tracker" |
| 25 | +} |
| 26 | + |
| 27 | +@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date = on-sync date" { |
| 28 | + export releasedate=$(date -d "-28day" +%Y-%m-%d) |
| 29 | + ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh |
| 30 | + |
| 31 | + # Assert result. |
| 32 | + assert_output --partial "Dry-run enabled, no changes will be performed to the tracker" |
| 33 | +} |
| 34 | + |
| 35 | +@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Current date > on-sync date" { |
| 36 | + export releasedate=$(date -d "-29day" +%Y-%m-%d) |
| 37 | + ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh |
| 38 | + |
| 39 | + # Assert result. |
| 40 | + assert_failure |
| 41 | + assert_output --partial "ERROR: The current date is already past the on-sync period. Please make sure the Release date (${releasedate}) is configured correctly." |
| 42 | +} |
| 43 | + |
| 44 | +@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Invalid release date format" { |
| 45 | + export releasedate=$(date +%m-%d-%Y) |
| 46 | + export lastweekdate=$(date +%Y-%m-%d) |
| 47 | + ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh |
| 48 | + |
| 49 | + # Assert result. |
| 50 | + assert_failure |
| 51 | + assert_output --partial "ERROR: \$releasedate. Incorrect YYYY-MM-DD format detected: ${releasedate}" |
| 52 | +} |
| 53 | + |
| 54 | +@test "tracker_automations/continuous_manage_queues/continuous_manage_queues.sh: Invalid last week date format" { |
| 55 | + export releasedate=$(date -d "+7day" +%Y-%m-%d) |
| 56 | + export lastweekdate=$(date +%m-%d-%Y) |
| 57 | + ci_run tracker_automations/continuous_manage_queues/continuous_manage_queues.sh |
| 58 | + |
| 59 | + # Assert result. |
| 60 | + assert_failure |
| 61 | + assert_output --partial "ERROR: \$lastweekdate. Incorrect YYYY-MM-DD format detected: ${lastweekdate}" |
| 62 | +} |
0 commit comments