-
Notifications
You must be signed in to change notification settings - Fork 369
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
test: v4 signed URL: conformance test #638
Conversation
This reverts commit ce00255.
ae246f7
to
079af08
Compare
conformance-test/v4SignedUrl.ts
Outdated
}); | ||
|
||
// tslint:disable-next-line:no-any | ||
testCases.forEach((testCase: any) => { |
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.
With this pattern, when a test fails - you're going to get a stack trace that points to code in a loop. How are we going to know specifically which code is failing? I don't have a great answer, but I personally really dislike debugging these kinds of tests-in-a-loopsie-loop thingies. Wondering if @bcoe has an answer.
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.
I've never loved this pattern in tests (auto generating the description feels pretty clever, and makes it hard to grep the codebase for a specific test case).
I might instead look into using a snapshot pattern, it's really similar but addresses some of @JustinBeckwith's concerns, and I think is a really cool pattern to have in our tool-belt. It works like this:
You have a unit test with an assertion that looks like this:
test.js
it('reports coverage for script that exits normally', () => {
const { output } = runSomeOperation()
output.should.matchSnapshot()
})
You have a snapshot file that maps the assertion names to captured outputs:
test.js.snapshot
exports[`reports coverage for script that exits normally`] = {"recorded snapshot output": "foo bar"};
You tend to pair this pattern with some process for generation, and you run the snapshots in generation mode when changes have been made -- in your case this might be changes to a fixture.
Here's the library I've been using to add this functionality to mocha
, I really love it:
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.
I wouldn't block landing this on introducing snapshots, but I think they're potentially a great abstraction for adding this type of test to code-bases and worth considering.
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.
LGTM - only ask - please file a follow up issue to clean up the tests happening in a loop. We don't need to do it in this PR, but it's a good thing as a cleanup label to go explore snapshots.
* feat: v4 signed url WIP * make version an optinoal * lint * add required host header * fix canonical query params joining * add test for defaulting to v2 * fix v4 signing with test * fix tests * refactor post-signing url construction v2/v4 * add v4 tests: response-content-type and generate parameters * convert signature to HEX * add conformance test * npm run fix * remove reduntant toLowerCase * do not promisify getDate() * add system-test for v4 signing * run conformance test along with system test * fix tests * add content-md5 and content-type to signed headers if given * Object.entries in not ES5 * npm run fix * split out conformance test * test: invalid version param given * mock out Date when testing instead of override Date * use Array.map to build canonical query * refactor: use dateformat library instead of writing a function * refactor: remove unused * remove reference to deleted methods * refactor: use string interpolation and dot accessor * refactor: use method chaining * add a comment about singled valued header * refactor signedHeaders * Number(x) * refactor: use query-string module as url.parse is deprecated * npm run fix * use query-string to build canonicalQueryParams * refactor: verb => method * refactor: use sinon.FakeTimers instead of timekeeper * npm run fix * use async/await for new system-test * use async/await for new test (2) * convert getSignedUrl tests to async/await * refactor: correctly filter out undefined header values * npm run fix * make v4 multi-valued header delimiter consistent with v2, (single `,`, no space) * copy stack trace * fix: replace ALL sequential spaces * OutgoingHttpHeaders use generic type .map; rename flattenObject => objectEntries * refactor: use build-in querystring * break up v2/v4 signed url query interface * add comments about the construction of canonical headers * npm run fix * git merge failed to put code in right place * test: assert SigningError thrown * test(v4): resumable upload * prefer string.includes over indexOf * npm run fix * docs: add a note on POST and X-Goog-Resumable * SEVEN_DAYS = 604800 * emit warning when using default version * emitWarning if using default version for signing * restore stub * add new line * test: v4 signed URL: conformance test (#638) * Revert "split out conformance test" This reverts commit ce00255. * sync conformance-test cases; parse cases without modification * this.skip * refactor: lift interface * remove default v2 warning * docs(samples): Samples for v4 Signed URL (#654) * remove timeout on conformance-test * npm run fix
No description provided.