diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-07 17:39:34 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-07 17:39:34 +0900 |
| commit | 093e30c78872a5d8605de4b2a3aeb35abca63835 (patch) | |
| tree | 15e87de000864f78f7c02a5c1f12ed829027b5d8 /internal/system/dispatcher_test.go | |
| parent | 1b17ccda914de78a88e1edbb42ce70d963d4b5a2 (diff) | |
internal/system: integrate PipeWire SecurityContext
Tests for this Op happens to be the best out of everything due to the robust infrastructure offered by internal/pipewire.
This is now ready to use in internal/outcome for implementing #26.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system/dispatcher_test.go')
| -rw-r--r-- | internal/system/dispatcher_test.go | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/internal/system/dispatcher_test.go b/internal/system/dispatcher_test.go index ed162171..f69422c9 100644 --- a/internal/system/dispatcher_test.go +++ b/internal/system/dispatcher_test.go @@ -14,6 +14,7 @@ import ( "hakurei.app/hst" "hakurei.app/internal/acl" "hakurei.app/internal/dbus" + "hakurei.app/internal/pipewire" "hakurei.app/internal/xcb" ) @@ -245,8 +246,16 @@ func (k *kstub) mkdir(name string, perm os.FileMode) error { func (k *kstub) chmod(name string, mode os.FileMode) error { k.Helper() - return k.Expects("chmod").Error( - stub.CheckArg(k.Stub, "name", name, 0), + expect := k.Expects("chmod") + + // translate ignored name + nameVal := any(name) + if _, ok := expect.Args[0].(ignoreValue); ok { + nameVal = ignoreValue{} + } + + return expect.Error( + stub.CheckArgReflect(k.Stub, "name", nameVal, 0), stub.CheckArg(k.Stub, "mode", mode, 1)) } @@ -273,8 +282,16 @@ func (k *kstub) println(v ...any) { func (k *kstub) aclUpdate(name string, uid int, perms ...acl.Perm) error { k.Helper() - return k.Expects("aclUpdate").Error( - stub.CheckArg(k.Stub, "name", name, 0), + expect := k.Expects("aclUpdate") + + // translate ignored name + nameVal := any(name) + if _, ok := expect.Args[0].(ignoreValue); ok { + nameVal = ignoreValue{} + } + + return expect.Error( + stub.CheckArgReflect(k.Stub, "name", nameVal, 0), stub.CheckArg(k.Stub, "uid", uid, 1), stub.CheckArgReflect(k.Stub, "perms", perms, 2)) } @@ -288,6 +305,12 @@ func (k *kstub) waylandNew(displayPath, bindPath *check.Absolute, appID, instanc stub.CheckArg(k.Stub, "instanceID", instanceID, 3)) } +func (k *kstub) pipewireConnect() (*pipewire.Context, error) { + k.Helper() + expect := k.Expects("pipewireConnect") + return expect.Ret.(func() *pipewire.Context)(), expect.Error() +} + func (k *kstub) xcbChangeHosts(mode xcb.HostMode, family xcb.Family, address string) error { k.Helper() return k.Expects("xcbChangeHosts").Error( @@ -387,7 +410,18 @@ func (k *kstub) Verbose(v ...any) { func (k *kstub) Verbosef(format string, v ...any) { k.Helper() - if k.Expects("verbosef").Error( + expect := k.Expects("verbosef") + + // translate ignores in v + if want, ok := expect.Args[1].([]any); ok && len(v) == len(want) { + for i, a := range want { + if _, ok = a.(ignoreValue); ok { + v[i] = ignoreValue{} + } + } + } + + if expect.Error( stub.CheckArg(k.Stub, "format", format, 0), stub.CheckArgReflect(k.Stub, "v", v, 1)) != nil { k.FailNow() |
