-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
hacktoberfesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedseverity-minorItem is not urgentItem is not urgent
Description
Hey guys, I came across a problem theses days, which was:
I needed to test a use case that had an external client call inside authorize(), like calling another micro service to check some user permissions before authorizing the use case execution.
I did realize that I could not inject the external client while testing, because .authorize() do not receive the use case context as a parameter, so I needed to mock the hole external client require or override the ._authorize()
const ucMyBusinessRule = MyBusinessRule()
ucMyBusinessRule._authorize = async () => {
return { isOk: true }
}
await ucMyBusinessRule.authorize()
const ret = await ucMyBusinessRule.run(parameters)
if (ret.isErr) console.log(ret.err)
const { ruleRet } = ret.ok
expect(ruleRet.isValid()).to.be.trueI dont know if its an real issue and we should add ctx inside the authorize() or that is the expected behavior, since its a convention to not use context inside authorize step. What your thoughts on this?
eacvortx, dalssoft and PedroHaupenthal
Metadata
Metadata
Assignees
Labels
hacktoberfesthelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedseverity-minorItem is not urgentItem is not urgent
Type
Projects
Status
More discussion is needed