Fix issue with bad updates causing disappearing tests #464
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.
Fixes #236
Pretty much similar to #414, but with an added test to show the issue.
Based on what @mathiasbynens said in that PR #414 (comment)
It seems like the original fix in #414 was correct. I have also written a test that shows the correct action.
If you are the owner of the test (aka you own the 1st revision), only you (with the
isOwnflag set to true) should be able to "update" an existing test. Otherwise you are not the owner and you should only be inserting your test cases into a revision.The reason for all the tests having "empty" test cases is because the code would fall into the UPDATE sql statement every single time regardless of whether you're the actual owner or not because each test always passes a testID unless a new test case is added to your revision of the test.
E.g. every test has the two basic test cases, and so if you try to create a new revision and only edit those 2 test cases, you'll get a blank test revision. If you add an extra test case in that revision, then that one won't have a
testIDand thus will make an INSERT call and this new revision will only have the new test case.The additional test case shows that if you are the owner, you make updates if the test cases exist, and if you are not the owner you only make inserts.