Skip to content

Conversation

@invidian
Copy link

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 [email protected]

This PR replaces #396, since the original fork has been archived and I am not able to update it. CC @kolyshkin

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 <[email protected]>
Copy link
Collaborator

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do

	. "github.com/coreos/go-systemd/v22/login1"

instead, to avoid modifications to the rest of the file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <[email protected]>
@invidian invidian force-pushed the invidian/new-with-connection branch from 5a0b55b to d01e987 Compare January 29, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants