-
Notifications
You must be signed in to change notification settings - Fork 9
NOISSUE - Add property based testing to users service #146
Conversation
c01a30f
to
5d8d612
Compare
@@ -130,6 +130,16 @@ test: | |||
done | |||
go test -v --race -count 1 -tags test -coverprofile=coverage/coverage.out $$(go list ./... | grep -v 'consumers\|readers\|postgres\|internal\|opcua\|cmd') | |||
|
|||
test_api: |
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.
Currently we are testing one api users
when I add the next API things
I will make this command support different apis
746f305
to
4fbcccd
Compare
128e340
to
c9b4482
Compare
e896974
to
ceebb92
Compare
ceebb92
to
2df995f
Compare
@rodneyosodo |
82fda87
to
0ed62f9
Compare
Sometimes schemathesis doesn't evaluate links well. This is an example where links have been executed https://github.com/absmach/magistrala/actions/runs/7372122967/job/20060147579?pr=164 When links are used in the swagger file, schemathesis is able to do stateful testing hence there will be OK logs since once an entity has been created it can fuzz the update entity URL using the created entity ID |
f8c16fe
to
362f287
Compare
st run api/openapi/users.yml \ | ||
--checks all \ | ||
--base-url http://localhost:9002 \ | ||
--header "Authorization: Bearer $(USER_TOKEN)" \ |
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 will be great if we have some kind of automated script which will do task of getting user token and setting to variable USER_TOKEN
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 happens only in CI should we change this approach https://github.com/rodneyosodo/magistrala-dev/blob/users-schemathesis/.github/workflows/api-tests.yml#L38C1-L41C55 ?
internal/api/common.go
Outdated
errors.Contains(err, svcerr.ErrViewEntity), | ||
errors.Contains(err, repoerr.ErrFailedToRetrieveAllGroups), | ||
errors.Contains(err, repoerr.ErrAddPolicies), | ||
errors.Contains(err, repoerr.ErrDeletePolicies), | ||
errors.Contains(err, svcerr.ErrRemoveEntity): |
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.
Why don't we have only wrap repo error in service layer error and handle only svc error in error encoder?
Because repo errors returns error messages from repo, which is irrevlant to user
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 have wrapped the respective repo errors
f2f2513
to
ef1423e
Compare
f56e6b2
to
ada324d
Compare
ada324d
to
0d81807
Compare
Signed-off-by: Rodney Osodo <[email protected]>
0d81807
to
7b61646
Compare
Closed in favour of https://github.com/absmach/magistrala/pull/2087 |
What type of PR is this?
This is a feature PR as it adds property-based testing to users API. In addition it is a refactor to error handling on the API
What does this do?
Adds schemathesis to users service
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Yes, I have included tests for my changes.
Did you document any new/modified feature?
No
Notes