@@ -69,3 +69,183 @@ jobs:
69
69
exit 1
70
70
fi
71
71
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
72
+
73
+ test-previews :
74
+ name : ' Integration test: previews option'
75
+ runs-on : ubuntu-latest
76
+ steps :
77
+ - uses : actions/checkout@v3
78
+ - uses : actions/cache@v3
79
+ with :
80
+ path : ~/.npm
81
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
82
+ restore-keys : ${{runner.os}}-npm-
83
+ - run : npm ci
84
+ - id : previews-default
85
+ name : Default previews not set
86
+ uses : ./
87
+ with :
88
+ script : |
89
+ const endpoint = github.request.endpoint
90
+ return endpoint({}).headers.accept
91
+ result-encoding : string
92
+ - id : previews-set-single
93
+ name : Previews set to a single value
94
+ uses : ./
95
+ with :
96
+ previews : foo
97
+ script : |
98
+ const endpoint = github.request.endpoint
99
+ return endpoint({}).headers.accept
100
+ result-encoding : string
101
+ - id : previews-set-multiple
102
+ name : Previews set to comma-separated list
103
+ uses : ./
104
+ with :
105
+ previews : foo,bar,baz
106
+ script : |
107
+ const endpoint = github.request.endpoint
108
+ return endpoint({}).headers.accept
109
+ result-encoding : string
110
+ - run : |
111
+ echo "- Validating previews default"
112
+ expected="application/vnd.github.v3+json"
113
+ if [[ "${{steps.previews-default.outputs.result}}" != $expected ]]; then
114
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-default.outputs.result}}"
115
+ exit 1
116
+ fi
117
+ echo "- Validating previews set to a single value"
118
+ expected="application/vnd.github.foo-preview+json"
119
+ if [[ "${{steps.previews-set-single.outputs.result}}" != $expected ]]; then
120
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-single.outputs.result}}"
121
+ exit 1
122
+ fi
123
+ echo "- Validating previews set to multiple values"
124
+ expected="application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json,application/vnd.github.baz-preview+json"
125
+ if [[ "${{steps.previews-set-multiple.outputs.result}}" != $expected ]]; then
126
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.previews-set-multiple.outputs.result}}"
127
+ exit 1
128
+ fi
129
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
130
+
131
+ test-user-agent :
132
+ name : ' Integration test: user-agent option'
133
+ runs-on : ubuntu-latest
134
+ steps :
135
+ - uses : actions/checkout@v3
136
+ - uses : actions/cache@v3
137
+ with :
138
+ path : ~/.npm
139
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
140
+ restore-keys : ${{runner.os}}-npm-
141
+ - run : npm ci
142
+ - id : user-agent-default
143
+ name : Default user-agent not set
144
+ uses : ./
145
+ with :
146
+ script : |
147
+ const endpoint = github.request.endpoint
148
+ return endpoint({}).headers['user-agent']
149
+ result-encoding : string
150
+ - id : user-agent-set
151
+ name : User-agent set
152
+ uses : ./
153
+ with :
154
+ user-agent : foobar
155
+ script : |
156
+ const endpoint = github.request.endpoint
157
+ return endpoint({}).headers['user-agent']
158
+ result-encoding : string
159
+ - id : user-agent-empty
160
+ name : User-agent set to an empty string
161
+ uses : ./
162
+ with :
163
+ user-agent : ' '
164
+ script : |
165
+ const endpoint = github.request.endpoint
166
+ return endpoint({}).headers['user-agent']
167
+ result-encoding : string
168
+ - run : |
169
+ echo "- Validating user-agent default"
170
+ expected="actions/github-script octokit-core.js/"
171
+ if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
172
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
173
+ exit 1
174
+ fi
175
+ echo "- Validating user-agent set to a value"
176
+ expected="foobar octokit-core.js/"
177
+ if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
178
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
179
+ exit 1
180
+ fi
181
+ echo "- Validating user-agent set to an empty string"
182
+ expected="octokit-core.js/"
183
+ if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
184
+ echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
185
+ exit 1
186
+ fi
187
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
188
+
189
+ test-debug :
190
+ name : ' Integration test: debug option'
191
+ runs-on : ubuntu-latest
192
+ steps :
193
+ - uses : actions/checkout@v3
194
+ - uses : actions/cache@v3
195
+ with :
196
+ path : ~/.npm
197
+ key : ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
198
+ restore-keys : ${{runner.os}}-npm-
199
+ - run : npm ci
200
+ - id : debug-default
201
+ name : Default debug not set
202
+ uses : ./
203
+ with :
204
+ script : |
205
+ const log = github.log
206
+ return {
207
+ debug: log.debug === console.debug,
208
+ info: log.info === console.info
209
+ }
210
+ - id : debug-true
211
+ name : Debug set to true
212
+ uses : ./
213
+ with :
214
+ debug : true
215
+ script : |
216
+ const log = github.log
217
+ return {
218
+ debug: log.debug === console.debug,
219
+ info: log.info === console.info
220
+ }
221
+ - id : debug-false
222
+ name : Debug set to false
223
+ uses : ./
224
+ with :
225
+ debug : false
226
+ script : |
227
+ const log = github.log
228
+ return {
229
+ debug: log.debug === console.debug,
230
+ info: log.info === console.info
231
+ }
232
+ - run : |
233
+ echo "- Validating debug default"
234
+ expected='{debug:false,info:false}'
235
+ if [[ "${{steps.debug-default.outputs.result}}" != "$expected" ]]; then
236
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-default.outputs.result}}"
237
+ exit 1
238
+ fi
239
+ echo "- Validating debug set to true"
240
+ expected='{debug:true,info:true}'
241
+ if [[ "${{steps.debug-true.outputs.result}}" != "$expected" ]]; then
242
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-true.outputs.result}}"
243
+ exit 1
244
+ fi
245
+ echo "- Validating debug set to false"
246
+ expected='{debug:false,info:false}'
247
+ if [[ "${{steps.debug-false.outputs.result}}" != "$expected" ]]; then
248
+ echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-false.outputs.result}}"
249
+ exit 1
250
+ fi
251
+ echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
0 commit comments