-
Notifications
You must be signed in to change notification settings - Fork 23
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
Refactor/guble 24 public router interface #46
Conversation
Fixed issue where messages would've been stored although no WRITE access was allowed.
routerMock.EXPECT().KVStore().Return(store.NewMemoryKVStore(), nil) | ||
routerMock.EXPECT().AccessManager().Return(amMock, nil).MaxTimes(2) | ||
routerMock.EXPECT().MessageStore().Return(msMock, nil).MaxTimes(2) |
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.
Maybe it would be better to have a had written struct based implementation of the router interface for testing,
then I could write something like
routerMock := routerMock{MessageStore: NewMockMessageStore(mockCtrl), ...}
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 is good point. Want this now in this PR?
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 prefer to have all things done before merging,
but if you prefer, I also can merge directly.
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 will add this first.
I have an idea here to extend the mock from the current mock generated in which the call to these methods return the supplied objects.
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.
There is a problem with this. Here I'm testing something in gubled
using a mock from server (RouterMock
). Re your comment above this means I should either:
- create a
RouterMock
inside thegubled
package in a_test.go
file and it will be visible only here. - create a public
RouterMock
in theserver
package and use it in other packages.
The other solution is to leave it as is, and everyone would supply the arguments according to the 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.
Would be the same with the generated mock.
I would never leave the mock code in the production code, so I see two possible solutions:
- have the mock redundant in the _test.go code of each package, where we need it
- Create a separate test_util package
In this small case I would prefer the redundancy variant.
It was a good decision to make this change: Make the code much simpler. |
I would merge it now, but the build fails. |
The build fails, but for us works ok locally. We will focus on test fixing from now in next PR's. |
No description provided.