-
Notifications
You must be signed in to change notification settings - Fork 35
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
Simplify testApi.mjs
#1135
Merged
Merged
Simplify testApi.mjs
#1135
Conversation
This file contains 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
pavpanchekha
commented
Jan 22, 2025
infra/test-api.js
Outdated
Comment on lines
118
to
194
const exactsBody = { | ||
method: 'POST', body: JSON.stringify({ | ||
formula: FPCoreFormula2, sample: eval_sample | ||
}) | ||
} | ||
const exacts = await (await fetch(makeEndpoint("/api/exacts"), exactsBody)).json() | ||
assertIdAndPath(exacts) | ||
assert.deepEqual(exacts.points, [[[1], -1.4142135623730951]]) | ||
const exactsAsyncResult = await callAsyncAndWaitJSONResult("/api/start/exacts", exactsBody) | ||
assertIdAndPath(exactsAsyncResult) | ||
assert.deepEqual(exactsAsyncResult.points, [[[1], -1.4142135623730951]]) | ||
await testAPI("/api/exacts", { | ||
formula: FPCoreFormula2, | ||
sample: eval_sample | ||
}, (body) => { | ||
assert.deepEqual(body.points, [[[1], -1.4142135623730951]]); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good example of the before/after.
fa9ef29
to
34cddc3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR significantly simplifies
testApi.mjs
(which it also renames) using a nicetestAPI
abstraction. Not every part of the code is ported over yet, but the bulk of it is; I may merge before porting everything or I might wait and keep going until everything looks pretty. As a minor extra improvement, thetest-api.js
script now also starts the server for you and has nicer command-line output with basic performance data.This PR, I think, obsoletes #1055. It's possible there are improvements in that PR that are worth porting over, I may or may not check, but I think this PR is better.
Funny enough, I was considering rewriting
test-api.js
into Racket so we don't depend onnode
, but the code is now pretty enough that I think it's not worth it.