Repository navigation
Conversation
the endpoint is now functional. however, there are a few non-functional changes to still make. 1. The pause and resume endpoint are nearly identical. It might be good to deduplicate them. 2. The authz tests need to be generalized
5 tasks done
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
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.
closes: coder/internal#1362
coderd/aitasks_test.gocontains a few different testing strategies. Some of the tests are also overly specific and should be generalized and then moved to the appropriate abstraction layer.This PR standardises our testing strategy for
coderd/aitasks_test.go.Feedback to address:
#21889 (comment)
Most, perhaps all, task endpoints get a workspace at some point. We have endpoint specific testing to ensure that if a workspace cannot be gotten, we fail correctly. Feedback from reviewers is that we'd like to enforce this failure mode for all task endpoints instead of testing it per endpoint. This is to avoid the risk of inconsistent behaviour between different endpoints.
Furthermore, Task Pause and Resume endpoints use a wrapper that induces the failure by overriding the method that we need to fail. Elsewhere in the tests,
dbgenanddbfakeare used to induce failures using real state in a database.The benefits to this are:
The drawbacks are:
Action items
#21889 (comment)
The original issue stated requirements related to authorization. These requirements were explicitly tested at the endpoint level, but those tests are deemed too specific and too granular. Per reviewer's request, these tests should be generalised and rather done at the rbac/dbauthz layer. At the endpoint level, it is sufficient to test using a second
memberuser and ensure that the response is correct.Action items
dbauthzlayer.memberuser.#21889 (comment)
Similar to the feedback above, reviewers request that we generalize testing for when resources cannot be found across all AI Task endpoints and ensure that the 404 response is correct.
✅ #21948 (comment)
Define variables closer to first use.