Skip to content

Commit

Permalink
Refactor Armstrong Number API tests and script command
Browse files Browse the repository at this point in the history
The URL format for Armstrong Number API tests has been updated to new specification. Additional assertions for response status, content type, and JSON body have also been included. Package.json script command is slightly modified for better output management.

@coderabbitai ignore
  • Loading branch information
rabestro committed Apr 16, 2024
1 parent 236c14b commit 4348481
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=9926315
url: {{host}}/api/armstrong-numbers/9926315
body: none
auth: none
}
Expand All @@ -15,5 +15,9 @@ query {
}

assert {
assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isTruthy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=9926314
url: {{host}}/api/armstrong-numbers/9926314
body: none
auth: none
}
Expand All @@ -15,5 +15,9 @@ query {
}

assert {
assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isFalsy
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ get {

assert {
res.status: eq 400
res.headers['content-type']: contains application/json
res.body: isJson
res.body.message: isDefined
res.body.message: contains pass a number
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=9474
url: {{host}}/api/armstrong-numbers/9474
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isTruthy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=9475
url: {{host}}/api/armstrong-numbers/9475
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isFalsy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=5
url: {{host}}/api/armstrong-numbers/5
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isTruthy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=10
url: {{host}}/api/armstrong-numbers/10
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isFalsy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=153
url: {{host}}/api/armstrong-numbers/153
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isTruthy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=100
url: {{host}}/api/armstrong-numbers/100
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isFalsy
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

get {
url: {{host}}/api/armstrong-numbers?number=0
url: {{host}}/api/armstrong-numbers/0
body: none
auth: none
}
Expand All @@ -15,5 +15,8 @@ query {
}

assert {
res.status: eq 200
res.headers['content-type']: contains application/json
res.body: isJson
res.body.isArmstrongNumber: isTruthy
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "cd exercism-api-tests && bru run --env azure --format junit --output ../report.xml",
"change": "cd exercism-api-tests/Change && bru run --env azure --format junit --output ../../report.xml"
"change": "cd exercism-api-tests && bru run Change --env azure --format junit --output ../report.xml"
},
"keywords": [
"bruno",
Expand Down

0 comments on commit 4348481

Please sign in to comment.