|
6 | 6 |
|
7 | 7 | load ../_helper.bash |
8 | 8 |
|
9 | | -@test "Notify: slack, branch" { |
| 9 | +@test "Notify: slack, branch pre_deployment" { |
10 | 10 | pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
11 | 11 |
|
12 | 12 | mock_curl=$(mock_command "curl") |
13 | 13 | mock_set_output "${mock_curl}" "200" 1 |
14 | 14 |
|
15 | | - export VORTEX_NOTIFY_CHANNELS="slack" |
16 | | - export VORTEX_NOTIFY_PROJECT="testproject" |
17 | | - export VORTEX_NOTIFY_BRANCH="develop" |
18 | | - export VORTEX_NOTIFY_SHA="abc123def456" |
19 | | - export VORTEX_NOTIFY_LABEL="develop" |
20 | | - export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com" |
| 15 | + export VORTEX_NOTIFY_SLACK_PROJECT="testproject" |
| 16 | + export VORTEX_NOTIFY_SLACK_LABEL="develop" |
| 17 | + export VORTEX_NOTIFY_SLACK_ENVIRONMENT_URL="https://develop.testproject.com" |
| 18 | + export VORTEX_NOTIFY_SLACK_LOGIN_URL="https://develop.testproject.com/user/login" |
21 | 19 | export VORTEX_NOTIFY_SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX" |
| 20 | + export VORTEX_NOTIFY_SLACK_CHANNEL="#deployments" |
| 21 | + export VORTEX_NOTIFY_SLACK_USERNAME="Deploy Bot" |
| 22 | + export VORTEX_NOTIFY_SLACK_ICON_EMOJI=":rocket:" |
| 23 | + export VORTEX_NOTIFY_SLACK_EVENT="pre_deployment" |
22 | 24 |
|
23 | | - run ./scripts/vortex/notify.sh |
| 25 | + run ./scripts/vortex/notify-slack.sh |
24 | 26 | assert_success |
25 | 27 |
|
26 | | - assert_output_contains "Started dispatching notifications." |
| 28 | + # Assert script output |
27 | 29 | assert_output_contains "Started Slack notification." |
28 | | - assert_output_contains "Notification sent to Slack." |
29 | | - assert_output_contains "Project: testproject" |
30 | | - assert_output_contains 'Deployment: develop' |
| 30 | + assert_output_contains "Project : testproject" |
| 31 | + assert_output_contains "Deployment : develop" |
31 | 32 | assert_output_contains "Environment URL: https://develop.testproject.com" |
| 33 | + assert_output_contains "Login URL : https://develop.testproject.com/user/login" |
| 34 | + assert_output_contains "Channel : #deployments" |
| 35 | + assert_output_contains "Username : Deploy Bot" |
| 36 | + assert_output_contains "Event : Deployment Starting" |
| 37 | + assert_output_contains "Notification sent to Slack." |
32 | 38 | assert_output_contains "Finished Slack notification." |
33 | | - assert_output_contains "Finished dispatching notifications." |
| 39 | + |
| 40 | + # Verify curl payload does NOT contain View Site or Login Here for pre-deployment |
| 41 | + run mock_get_call_args "${mock_curl}" 1 |
| 42 | + assert_output_contains "Deployment" |
| 43 | + assert_output_contains "Time" |
| 44 | + assert_output_not_contains "View Site" |
| 45 | + assert_output_not_contains "Login Here" |
34 | 46 |
|
35 | 47 | popd >/dev/null || exit 1 |
36 | 48 | } |
37 | 49 |
|
38 | | -@test "Notify: slack, PR" { |
| 50 | +@test "Notify: slack, branch post_deployment" { |
39 | 51 | pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
40 | 52 |
|
41 | 53 | mock_curl=$(mock_command "curl") |
42 | 54 | mock_set_output "${mock_curl}" "200" 1 |
43 | 55 |
|
44 | | - export VORTEX_NOTIFY_CHANNELS="slack" |
45 | | - export VORTEX_NOTIFY_PROJECT="testproject" |
46 | | - export VORTEX_NOTIFY_BRANCH="feature/feature-123" |
47 | | - export VORTEX_NOTIFY_SHA="abc123def456" |
48 | | - export VORTEX_NOTIFY_PR_NUMBER="123" |
49 | | - export VORTEX_NOTIFY_LABEL="PR-123" |
50 | | - export VORTEX_NOTIFY_ENVIRONMENT_URL="https://pr-123.testproject.com" |
| 56 | + export VORTEX_NOTIFY_SLACK_PROJECT="testproject" |
| 57 | + export VORTEX_NOTIFY_SLACK_LABEL="develop" |
| 58 | + export VORTEX_NOTIFY_SLACK_ENVIRONMENT_URL="https://develop.testproject.com" |
| 59 | + export VORTEX_NOTIFY_SLACK_LOGIN_URL="https://develop.testproject.com/user/login" |
51 | 60 | export VORTEX_NOTIFY_SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX" |
| 61 | + export VORTEX_NOTIFY_SLACK_CHANNEL="#deployments" |
| 62 | + export VORTEX_NOTIFY_SLACK_USERNAME="Deploy Bot" |
| 63 | + export VORTEX_NOTIFY_SLACK_ICON_EMOJI=":rocket:" |
| 64 | + export VORTEX_NOTIFY_SLACK_EVENT="post_deployment" |
52 | 65 |
|
53 | | - run ./scripts/vortex/notify.sh |
| 66 | + run ./scripts/vortex/notify-slack.sh |
54 | 67 | assert_success |
55 | 68 |
|
56 | | - assert_output_contains "Started dispatching notifications." |
| 69 | + # Assert script output |
57 | 70 | assert_output_contains "Started Slack notification." |
| 71 | + assert_output_contains "Project : testproject" |
| 72 | + assert_output_contains "Deployment : develop" |
| 73 | + assert_output_contains "Environment URL: https://develop.testproject.com" |
| 74 | + assert_output_contains "Login URL : https://develop.testproject.com/user/login" |
| 75 | + assert_output_contains "Channel : #deployments" |
| 76 | + assert_output_contains "Username : Deploy Bot" |
| 77 | + assert_output_contains "Event : Deployment Complete" |
58 | 78 | assert_output_contains "Notification sent to Slack." |
59 | | - assert_output_contains "Project: testproject" |
60 | | - assert_output_contains 'Deployment: PR-123' |
61 | | - assert_output_contains "Environment URL: https://pr-123.testproject.com" |
62 | 79 | assert_output_contains "Finished Slack notification." |
63 | | - assert_output_contains "Finished dispatching notifications." |
| 80 | + |
| 81 | + # Verify curl payload DOES contain View Site and Login Here for post-deployment |
| 82 | + run mock_get_call_args "${mock_curl}" 1 |
| 83 | + assert_output_contains "Deployment" |
| 84 | + assert_output_contains "Time" |
| 85 | + assert_output_contains "View Site" |
| 86 | + assert_output_contains "Login Here" |
64 | 87 |
|
65 | 88 | popd >/dev/null || exit 1 |
66 | 89 | } |
67 | 90 |
|
68 | | -@test "Notify: slack, pre_deployment" { |
| 91 | +@test "Notify: slack, PR pre_deployment" { |
69 | 92 | pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
70 | 93 |
|
71 | 94 | mock_curl=$(mock_command "curl") |
72 | 95 | mock_set_output "${mock_curl}" "200" 1 |
73 | 96 |
|
74 | | - export VORTEX_NOTIFY_CHANNELS="slack" |
75 | | - export VORTEX_NOTIFY_EVENT="pre_deployment" |
76 | | - export VORTEX_NOTIFY_PROJECT="testproject" |
77 | | - export VORTEX_NOTIFY_BRANCH="develop" |
78 | | - export VORTEX_NOTIFY_SHA="abc123def456" |
79 | | - export VORTEX_NOTIFY_LABEL="develop" |
80 | | - export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com" |
81 | | - export VORTEX_NOTIFY_SLACK_LOGIN_URL="https://develop.testproject.com/user/login" |
| 97 | + export VORTEX_NOTIFY_SLACK_PROJECT="testproject" |
| 98 | + export VORTEX_NOTIFY_SLACK_LABEL="PR-123" |
| 99 | + export VORTEX_NOTIFY_SLACK_ENVIRONMENT_URL="https://pr-123.testproject.com" |
| 100 | + export VORTEX_NOTIFY_SLACK_LOGIN_URL="https://pr-123.testproject.com/user/login" |
82 | 101 | export VORTEX_NOTIFY_SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX" |
| 102 | + export VORTEX_NOTIFY_SLACK_CHANNEL="#deployments" |
| 103 | + export VORTEX_NOTIFY_SLACK_USERNAME="Deploy Bot" |
| 104 | + export VORTEX_NOTIFY_SLACK_ICON_EMOJI=":rocket:" |
| 105 | + export VORTEX_NOTIFY_SLACK_EVENT="pre_deployment" |
83 | 106 |
|
84 | | - # Pre-deployment forces github channel, but we're testing slack directly |
85 | | - export VORTEX_NOTIFY_CHANNELS="github" |
| 107 | + run ./scripts/vortex/notify-slack.sh |
| 108 | + assert_success |
| 109 | + |
| 110 | + # Assert script output |
| 111 | + assert_output_contains "Started Slack notification." |
| 112 | + assert_output_contains "Project : testproject" |
| 113 | + assert_output_contains "Deployment : PR-123" |
| 114 | + assert_output_contains "Environment URL: https://pr-123.testproject.com" |
| 115 | + assert_output_contains "Login URL : https://pr-123.testproject.com/user/login" |
| 116 | + assert_output_contains "Channel : #deployments" |
| 117 | + assert_output_contains "Username : Deploy Bot" |
| 118 | + assert_output_contains "Event : Deployment Starting" |
| 119 | + assert_output_contains "Notification sent to Slack." |
| 120 | + assert_output_contains "Finished Slack notification." |
| 121 | + |
| 122 | + # Verify curl payload does NOT contain View Site or Login Here for pre-deployment |
| 123 | + run mock_get_call_args "${mock_curl}" 1 |
| 124 | + assert_output_contains "Deployment" |
| 125 | + assert_output_contains "Time" |
| 126 | + assert_output_not_contains "View Site" |
| 127 | + assert_output_not_contains "Login Here" |
| 128 | + |
| 129 | + popd >/dev/null || exit 1 |
| 130 | +} |
| 131 | + |
| 132 | +@test "Notify: slack, PR post_deployment" { |
| 133 | + pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1 |
| 134 | + |
| 135 | + mock_curl=$(mock_command "curl") |
| 136 | + mock_set_output "${mock_curl}" "200" 1 |
| 137 | + |
| 138 | + export VORTEX_NOTIFY_SLACK_PROJECT="testproject" |
| 139 | + export VORTEX_NOTIFY_SLACK_LABEL="PR-123" |
| 140 | + export VORTEX_NOTIFY_SLACK_ENVIRONMENT_URL="https://pr-123.testproject.com" |
| 141 | + export VORTEX_NOTIFY_SLACK_LOGIN_URL="https://pr-123.testproject.com/user/login" |
| 142 | + export VORTEX_NOTIFY_SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX" |
| 143 | + export VORTEX_NOTIFY_SLACK_CHANNEL="#deployments" |
| 144 | + export VORTEX_NOTIFY_SLACK_USERNAME="Deploy Bot" |
| 145 | + export VORTEX_NOTIFY_SLACK_ICON_EMOJI=":rocket:" |
| 146 | + export VORTEX_NOTIFY_SLACK_EVENT="post_deployment" |
86 | 147 |
|
87 | | - # Test Slack script directly for pre-deployment |
88 | | - export VORTEX_NOTIFY_CHANNELS="slack" |
89 | 148 | run ./scripts/vortex/notify-slack.sh |
90 | 149 | assert_success |
91 | 150 |
|
| 151 | + # Assert script output |
92 | 152 | assert_output_contains "Started Slack notification." |
| 153 | + assert_output_contains "Project : testproject" |
| 154 | + assert_output_contains "Deployment : PR-123" |
| 155 | + assert_output_contains "Environment URL: https://pr-123.testproject.com" |
| 156 | + assert_output_contains "Login URL : https://pr-123.testproject.com/user/login" |
| 157 | + assert_output_contains "Channel : #deployments" |
| 158 | + assert_output_contains "Username : Deploy Bot" |
| 159 | + assert_output_contains "Event : Deployment Complete" |
93 | 160 | assert_output_contains "Notification sent to Slack." |
94 | 161 | assert_output_contains "Finished Slack notification." |
95 | 162 |
|
| 163 | + # Verify curl payload DOES contain View Site and Login Here for post-deployment |
| 164 | + run mock_get_call_args "${mock_curl}" 1 |
| 165 | + assert_output_contains "Deployment" |
| 166 | + assert_output_contains "Time" |
| 167 | + assert_output_contains "View Site" |
| 168 | + assert_output_contains "Login Here" |
| 169 | + |
96 | 170 | popd >/dev/null || exit 1 |
97 | 171 | } |
98 | 172 |
|
|
0 commit comments