Conversation
This is a desired way of testing to avoid creating fragile test suites and be able to refactor code without touching tests. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
kolyshkin
left a comment
There was a problem hiding this comment.
It looks like there are API changes, meaning we'll need to target this to v23.
For v23, we can probably remove some deprecated stuff as well, and even rename some functions (but I don't have a plan yet).
Left a few nits, too.
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/coreos/go-systemd/v22/login1" |
There was a problem hiding this comment.
You can do
. "github.com/coreos/go-systemd/v22/login1"instead, to avoid modifications to the rest of the file.
There was a problem hiding this comment.
Thanks, although I am not sure I should do that. Conventionally, you write blackbox tests as you would be an external consumer of the code under test and most of the time code is imported into a separate namespace. I don't think skipping it buys a lot of extra readability in this case and optimizing the diff size doesn't seem like a convincing argument to derive from the convention to me.
Do you still want me to change that?
This method allows passing existing D-Bus connection, which allows to re-use connection between clients and to mock D-Bus connection for testing purposes. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
Closes coreos#388. Signed-off-by: Mateusz Gozdek <mgozdek@microsoft.com>
5a0b55b to
d01e987
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
Perhaps you should reverse the order of the last two commits, unless there's a compelling reason to keep it the way it is.
Adding something with TODO in it and then immediately solving this in the next commit seems like an unnecessary cognitive load to a reviewer.
|
If I swap the commits, I won't be able to test new code in login1: Use AddMatchSignalContext instead of BusObject.Call directly, since login1: Add NewWithConnection method enables testing, hence the original PRs split :) |
This method allows passing existing D-Bus connection, which allows to
re-use connection between clients and to mock D-Bus connection for
testing purposes.
Extracted from #390
Includes commits from #395
Signed-off-by: Mateusz Gozdek mgozdek@microsoft.com
This PR replaces #396, since the original fork has been archived and I am not able to update it. CC @kolyshkin