diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-14 01:33:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-14 01:33:44 +0900 |
| commit | 790d77075e40ee3162d7925e983f01747b5c2c89 (patch) | |
| tree | 56a59641aa87a40c9b28600ff8bd5d5642d95f5e /system/dbus_test.go | |
| parent | e5ff40e7d32d28cace183cd2c80f40f142855ff5 (diff) | |
system/dbus: remove builder state leak
This enables external testing of system.I state.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dbus_test.go')
| -rw-r--r-- | system/dbus_test.go | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/system/dbus_test.go b/system/dbus_test.go index 2a1f12db..a346711e 100644 --- a/system/dbus_test.go +++ b/system/dbus_test.go @@ -85,7 +85,7 @@ func TestDBusProxyOp(t *testing.T) { Op: "dbus", Err: ErrDBusConfig, Msg: "attempted to create message bus proxy args without session bus config", } - if err := sys.ProxyDBus(nil, new(hst.BusConfig), nil, nil); !reflect.DeepEqual(err, wantErr) { + if err := sys.ProxyDBus(nil, new(hst.BusConfig), dbus.ProxyPair{}, dbus.ProxyPair{}); !reflect.DeepEqual(err, wantErr) { t.Errorf("ProxyDBus: error = %v, want %v", err, wantErr) } }, nil, stub.Expect{}}, @@ -99,15 +99,20 @@ func TestDBusProxyOp(t *testing.T) { }() sys.MustProxyDBus( - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &hst.BusConfig{ + &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"session\x00"}, Filter: true, - }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &hst.BusConfig{ + }, &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, + }, dbus.ProxyPair{ + "unix:path=/run/user/1000/bus", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus", + }, dbus.ProxyPair{ + "unix:path=/run/dbus/system_bus_socket", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket", }) }, nil, stub.Expect{Calls: []stub.Call{ - call("dbusAddress", stub.ExpectArgs{}, [2]string{"unix:path=/run/user/1000/bus", "unix:path=/run/dbus/system_bus_socket"}, nil), call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, @@ -128,13 +133,16 @@ func TestDBusProxyOp(t *testing.T) { }, &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, - }, - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket")); !reflect.DeepEqual(err, wantErr) { + }, dbus.ProxyPair{ + "unix:path=/run/user/1000/bus", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus", + }, dbus.ProxyPair{ + "unix:path=/run/dbus/system_bus_socket", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket", + }); !reflect.DeepEqual(err, wantErr) { t.Errorf("ProxyDBus: error = %v", err) } }, nil, stub.Expect{Calls: []stub.Call{ - call("dbusAddress", stub.ExpectArgs{}, [2]string{"unix:path=/run/user/1000/bus", "unix:path=/run/dbus/system_bus_socket"}, nil), call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, @@ -145,12 +153,18 @@ func TestDBusProxyOp(t *testing.T) { {"full", 0xcafebabe, func(_ *testing.T, sys *I) { sys.MustProxyDBus( - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &hst.BusConfig{ + &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"session\x00"}, Filter: true, - }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &hst.BusConfig{ + }, &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, + }, dbus.ProxyPair{ + "unix:path=/run/user/1000/bus", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus", + }, dbus.ProxyPair{ + "unix:path=/run/dbus/system_bus_socket", + "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket", }) }, []Op{ &dbusProxyOp{ @@ -158,7 +172,6 @@ func TestDBusProxyOp(t *testing.T) { system: true, }, }, stub.Expect{Calls: []stub.Call{ - call("dbusAddress", stub.ExpectArgs{}, [2]string{"unix:path=/run/user/1000/bus", "unix:path=/run/dbus/system_bus_socket"}, nil), call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, |
