Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
holi-notifications
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
app
holi-notifications
Commits
325fdb28
Commit
325fdb28
authored
5 months ago
by
Ole Langbehn
Browse files
Options
Downloads
Patches
Plain Diff
Revert "forgot to add smoketest directory"
This reverts commit
70cc52d7
.
parent
70cc52d7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smoketest/main.js
+0
-41
0 additions, 41 deletions
smoketest/main.js
with
0 additions
and
41 deletions
smoketest/main.js
deleted
100644 → 0
+
0
−
41
View file @
70cc52d7
import
http
from
'
k6/http
'
import
{
check
,
sleep
}
from
'
k6
'
// You don't need to change anything in this section, it's k6 glue code.
// See the default function at the end of the file for defining your smoketest.
// This configuration only executes 1 test, enough for a smoketest. The smoketest will fail on any check failing.
const
allChecksNeedToPassTreshold
=
{
checks
:
[{
threshold
:
'
rate==1
'
,
abortOnFail
:
true
}]
}
export
const
options
=
{
vus
:
1
,
iterations
:
1
,
thresholds
:
allChecksNeedToPassTreshold
,
}
/**
* Performs a GraphQL query and checks the response using the provided function. Fails if any of the provided expectations are not met.
* @param {string} query The GraphQL query to perform
* @param {(response: http.Response) => Array<boolean>} checkFunction
* A function that takes the HTTP response as an argument and returns an array
* of boolean values, each indicating success or failure of a test.
*/
function
forQuery
(
query
,
checkFunction
)
{
const
response
=
http
.
post
(
`
${
__ENV
.
BASE_URL
}
`
,
JSON
.
stringify
({
query
}),
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
})
checkFunction
(
response
)
}
// Define your smoketest(s) here.
export
default
()
=>
{
forQuery
(
`{preferences{id}}`
,
(
response
)
=>
{
check
(
response
,
{
'
is status 200
'
:
(
r
)
=>
r
.
status
===
200
,
})
check
(
JSON
.
parse
(
response
.
body
),
{
// there can be multiple tests here, e.g.
//"contains topics object": (r) => typeof r.data.topics != null,
'
returns unauthorized error
'
:
(
r
)
=>
r
.
errors
[
0
].
message
===
"
Unauthorized
"
,
})
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment