-
Notifications
You must be signed in to change notification settings - Fork 4
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
WOR-1817: Refactor api service tests #3033
Conversation
@@ -57,7 +57,7 @@ trait WorkspaceApiService extends UserInfoDirectives { | |||
} | |||
} ~ | |||
path("workspaces" / "tags") { | |||
parameters('q.?, "limit".as[Int].optional) { (queryString, limit) => | |||
parameters(Symbol("q").?, "limit".as[Int].optional) { (queryString, limit) => |
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 isn't functional - it's just that the previous syntax is deprecated.
@@ -79,13 +79,6 @@ trait WorkspaceApiService extends UserInfoDirectives { | |||
} | |||
} ~ | |||
path("workspaces" / Segment / Segment) { (workspaceNamespace, workspaceName) => | |||
/* we enforce a 6-character minimum for workspaceNamespace, as part of billing project creation. |
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 comment hasn't been true since the paths were re-ordered for correct path specificity.
In this PR however, we can finally demonstrate that this is true.
entity(as[Set[WorkspaceACLUpdate]]) { aclUpdate => | ||
val inviteUsersNotFoundValue = inviteUsersNotFound match { |
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 fixes a bug discovered in testing, where if the query string contained an empty arg (eg: ?inviteUsersNotFound=
), the service would throw a 500 because it tries to call .toBoolean
on an empty string, which fails with an IllegalArgumentException
.
override val bucketMigrationServiceConstructor: RawlsRequestContext => BucketMigrationService = _ => | ||
mock[BucketMigrationService], | ||
override val userServiceConstructor: RawlsRequestContext => UserService = _ => mock[UserService] | ||
)(implicit val executionContext: ExecutionContext) |
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.
The basic purpose of this is:
- set up default mocks with no functionality, so you only need to specify the ones you care about
- set up paths that reflect those in
RawlsApiService
, but without the parts that we don't care about, such as metrics and logging.
@@ -1439,4 +1447,68 @@ class SubmissionApiServiceSpec extends ApiServiceSpec with TableDrivenPropertyCh | |||
} | |||
} | |||
} | |||
|
|||
it should "return a 201 when a comment is updated" in { |
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.
These were in the original POC - so I might as well include them.
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.
The diff is kind of useless, because basically the entire file was replaced. I'd recommend just looking at the new file when reviewing.
…re with usage of new setup patterns
d5172ea
to
4a46df5
Compare
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.
What does the change in coverage in the WorkspaceService
look like?
class MockApiService( | ||
val userInfo: UserInfo = | ||
UserInfo(RawlsUserEmail(""), OAuth2BearerToken("token"), 123, RawlsUserSubjectId("123456789876543212349")), | ||
override val openIDConnectConfiguration: OpenIDConnectConfiguration = mock[OpenIDConnectConfiguration], |
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.
Would it be worth setting these to RETURN_SMART_NULLS
to help people figure out what calls aren't getting mocked correctly when they're writing a new 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.
Good idea.
A 3% reduction in coverage (about 40 lines). The most significant losses are in I'll make a follow on ticket to add tests for those. |
Created WOR-1823 for follow-on test coverage. |
Ticket: https://broadworkbench.atlassian.net/browse/WOR-1817
Create better testing setup for api-level tests, and apply to workspace service api.
PR checklist
model/
, then you should publish a new officialrawls-model
and updaterawls-model
in Orchestration's dependencies.