-
Notifications
You must be signed in to change notification settings - Fork 44
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: Add cid (time-travel) query tests #539
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #539 +/- ##
===========================================
+ Coverage 54.42% 54.71% +0.28%
===========================================
Files 97 97
Lines 13174 13174
===========================================
+ Hits 7170 7208 +38
+ Misses 5325 5297 -28
+ Partials 679 669 -10
|
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.
Very minor suggestions, but straightforward additions, so this is an easy one 👍
func TestQuerySimpleWithUnknownCidAndInvalidDocKey(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple query with unknown cid and invalid dockey", | ||
Query: `query { | ||
users ( | ||
cid: "bafybeid57gpbwi4i6bg7g357vwwyzsmr4bjo22rmhoxrwqvdxlqxcgaqvu", | ||
dockey: "invalid docKey" | ||
) { | ||
Name | ||
} | ||
}`, | ||
Docs: map[int][]string{ | ||
0: { | ||
`{ | ||
"Name": "John", | ||
"Age": 21 | ||
}`, | ||
}, | ||
}, | ||
ExpectedError: "failed to get block in blockstore: ipld: could not find", | ||
} | ||
|
||
executeTestCase(t, test) |
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.
suggestion(non-blocking): this can broken into two tests, invalid doc key, and non-existing CID
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.
It actually doesnt care about the dockey format - there is a test that shows this, but the error is just that it couldn't find the cid (TestQuerySimpleWithUnknownCidAndInvalidDocKey)
|
||
func TestQuerySimpleWithCidAndDocKey(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple query with cid and dockey", |
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.
suggestion: All three of these tests have the same description. Should add more context, so when it errors out and dumps the description to the terminal it's more meaningful.
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.
My bad - I though I tweaked all of those. Will change
- fix descriptions
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package simple |
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.
suggestion: Add a test case that has multiple updates, right now the most updates being applied is 1.
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.
future work can be done to add concurrent updates, but this is far out of scope of this PR as the testing framework doesn't support concurrent updates (causing a forked/multi head situation).
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.
suggestion: Add a test case that has multiple updates, right now the most updates being applied is 1.
I was tempted to add that just to test getting a 'middle' cid, but otherwise I struggled to see how it could break that way. I guess I'll add one lol
- add 'middle' cid test
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.
Theres prob a number of steps the code skips if there is only the root version and 1 extra version, as it doesn't have to work as hard to iterate over all the versions and reconstruct as much.
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package one_to_many |
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.
thought: As mentioned on discord, I don't think these kinds of queries should be supported yet, as the return document will violate the "Time travel" mechanic since the root document will be the target version (cid) but the sub document won't be.
95ce7cf
to
e71e6ec
Compare
Add cid (time-travel) query tests
Relevant issue(s)
Resolves #526
Description
Adds integration tests for cid (time-travel) queries. A many of these tests document undesired features - when reviewing keep an eye out for test-function level documentation and feel very free to correct/object to my opinions expressed in those.
Tasks
Specify the platform(s) on which this was tested: