-
Notifications
You must be signed in to change notification settings - Fork 1
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
Test fixes #12
Test fixes #12
Conversation
Adjusted all tests so all are passing now.
@soywod review pls |
@soywod could you also please answer my suggestion with the |
Mmh I'm not so fan of having testing code outside of tests modules. It's not sth I've seen in other libs. I think we should not mix up codes. A dedicated function or a macro inside tests modules sounds more straightforward to me (and a better solution). |
Hold on, you're missunderstanding something. #[cfg(tests)]
pub trait Test {
fn get_test() -> Self;
} and then you can do the following for example for #[cfg(tests)]
impl Test for Msg {
fn test() -> Self {
// normal stuff
}
}```
} |
What are the benefits of such a trait? I mean, we could just write tests directly inside the test module, why bothering with implementing a trait? Sorry if I don't understand well what you mean. |
Because I think that it would safe us some duplicated code. Let's say you need a |
The |
No wait, I don't want to force you!!! I just saw that you also used an account in the test for |
No no you don't force me, I don't see the need but your are the one refactoring so you should know better, I really trust you! If you think it is needed then you can go, really 😃 |
hm... ok, I'll think about it how to fix this... |
Adjusted all tests so all are passing now.
Question
While I was refactoring the tests, I encountered often pretty duplicated code like in the doc example of
config/model.rs
for thenew_with_envelope
method... I was thinking to create a new trait, which is only active during tests which you can use to create instances of a struct with real-case values, which makes it different compared to theDefault
trait.In summary:
The
Test
trait should make it possible, to create new instances of a struct with near real-case attributes for testing while theDefault
trait can include "empty" attributes (like an empty vector orNone
and so on). What do you think?