-
Notifications
You must be signed in to change notification settings - Fork 21
feat(cts): add tests for host, user agent, and timeouts #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e81ca0a
chore: add tests for host, user agent, and timeouts
eunjae-lee 4639c12
chore: rename test
eunjae-lee df19ea0
chore: add more tests
eunjae-lee 6980d57
fix: add host to EchoResponse
eunjae-lee 4a61b97
chore: rename tests
eunjae-lee 09a6488
chore: fix host test and add region test
eunjae-lee a3a4248
Update suite.mustache
3cc180b
Merge branch 'main' into chore/add-client-tests
e73da28
Merge branch 'main' into chore/add-client-tests
46fba38
chore: update generated tests
eunjae-lee 42b1a53
Merge branch 'main' into chore/add-client-tests
eunjae-lee b3c0b26
update tests for region
eunjae-lee 60877e8
fix wrong timeouts
eunjae-lee 36328ad
Merge branch 'main' into chore/add-client-tests
eunjae-lee df28d2c
Merge branch 'chore/add-client-tests' of github.com:algolia/api-clien…
eunjae-lee f31b4b0
wip
eunjae-lee 835e92a
update region tests
eunjae-lee 057a31f
Merge branch 'main' into chore/add-client-tests
eunjae-lee 47032fc
Merge branch 'main' into chore/add-client-tests
eunjae-lee c676961
Merge branch 'main' into chore/add-client-tests
eunjae-lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[ | ||
{ | ||
"testName": "calls api with correct user agent", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "addABTests", | ||
"parameters": [ | ||
{ | ||
"name": "test", | ||
"variant": [{ "index": "my-test-index", "trafficPercentage": 90 }], | ||
"endAt": "2022-02-01T13:37:01Z" | ||
} | ||
], | ||
"expected": { | ||
"testSubject": "actual.userAgent", | ||
"match": { | ||
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "calls api with correct timeouts", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "addABTests", | ||
"parameters": [ | ||
{ | ||
"name": "test", | ||
"variant": [{ "index": "my-test-index", "trafficPercentage": 90 }], | ||
"endAt": "2022-02-01T13:37:01Z" | ||
} | ||
], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"connectTimeout": 2, | ||
"responseTimeout": 30 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"testName": "fallbacks to the alias when region is not given", | ||
"autoCreateClient": false, | ||
"steps": [ | ||
{ | ||
"type": "createClient", | ||
"parameters": { | ||
"appId": "my-app-id", | ||
"apiKey": "my-api-key", | ||
"region": "" | ||
}, | ||
"expected": { | ||
"error": false | ||
} | ||
}, | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "getABTest", | ||
"parameters": [ | ||
{ | ||
"id": "test" | ||
} | ||
], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"host": "analytics.algolia.com" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[ | ||
{ | ||
"testName": "calls api with correct user agent", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "getAverageClickPosition", | ||
"parameters": [{ "index": "my-index" }], | ||
"expected": { | ||
"testSubject": "actual.userAgent", | ||
"match": { | ||
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "calls api with correct timeouts", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "getAverageClickPosition", | ||
"parameters": [{ "index": "my-index" }], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"connectTimeout": 2, | ||
"responseTimeout": 5 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[ | ||
shortcuts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"testName": "calls api with correct user agent", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "pushEvents", | ||
"parameters": [ | ||
{ | ||
"events": [] | ||
} | ||
], | ||
"expected": { | ||
"testSubject": "actual.userAgent", | ||
"match": { | ||
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "calls api with correct timeouts", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "pushEvents", | ||
"parameters": [ | ||
{ | ||
"events": [] | ||
} | ||
], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"connectTimeout": 2, | ||
"responseTimeout": 30 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[ | ||
{ | ||
"testName": "fallbacks to the alias when region is not given", | ||
"autoCreateClient": false, | ||
"steps": [ | ||
{ | ||
"type": "createClient", | ||
"parameters": { | ||
"appId": "my-app-id", | ||
"apiKey": "my-api-key", | ||
"region": "" | ||
}, | ||
"expected": { | ||
"error": false | ||
} | ||
}, | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "pushEvents", | ||
"parameters": [{ "events": [] }], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"host": "insights.algolia.io" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[ | ||
{ | ||
"testName": "calls api with correct user agent", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "getPersonalizationStrategy", | ||
"parameters": [], | ||
"expected": { | ||
"testSubject": "actual.userAgent", | ||
"match": { | ||
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "calls api with correct timeouts", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "getPersonalizationStrategy", | ||
"parameters": [], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"connectTimeout": 2, | ||
"responseTimeout": 5 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"testName": "throws when region is not given", | ||
"autoCreateClient": false, | ||
"steps": [ | ||
{ | ||
"type": "createClient", | ||
"parameters": { | ||
"appId": "my-app-id", | ||
"apiKey": "my-api-key", | ||
"region": "" | ||
}, | ||
"expected": { | ||
"error": "`region` is missing." | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "does not throw when region is given", | ||
"autoCreateClient": false, | ||
"steps": [ | ||
{ | ||
"type": "createClient", | ||
"parameters": { | ||
"appId": "my-app-id", | ||
"apiKey": "my-api-key", | ||
"region": "us" | ||
}, | ||
"expected": { | ||
"error": false | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[ | ||
{ | ||
"testName": "calls api with correct user agent", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "createConfig", | ||
"parameters": [{}], | ||
"expected": { | ||
"testSubject": "actual.userAgent", | ||
"match": { | ||
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"testName": "calls api with correct timeouts", | ||
"steps": [ | ||
{ | ||
"type": "method", | ||
"object": "$client", | ||
"path": "createConfig", | ||
"parameters": [{}], | ||
"expected": { | ||
"match": { | ||
"objectContaining": { | ||
"connectTimeout": 2, | ||
"responseTimeout": 30 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.