aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/outcome/sppipewire_test.go
blob: 1e3dab6a250caf1ffdc5066bb4901887372e5bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package outcome

import (
	"testing"

	"hakurei.app/container"
	"hakurei.app/hst"
	"hakurei.app/internal/pipewire"
	"hakurei.app/internal/stub"
	"hakurei.app/internal/system"
)

func TestSpPipeWireOp(t *testing.T) {
	t.Parallel()
	config := hst.Template()

	checkOpBehaviour(t, []opBehaviourTestCase{
		{"not enabled", func(bool, bool) outcomeOp {
			return new(spPipeWireOp)
		}, func() *hst.Config {
			c := hst.Template()
			*c.Enablements = 0
			return c
		}, nil, nil, nil, nil, errNotEnabled, nil, nil, nil, nil, nil},

		{"success", func(bool, bool) outcomeOp {
			return new(spPipeWireOp)
		}, func() *hst.Config {
			c := hst.Template()
			c.DirectPipeWire = true
			return c
		}, nil, []stub.Call{}, newI().
			// state.instance
			Ephemeral(system.Process, m(wantInstancePrefix), 0711).
			// toSystem
			PipeWire(
				m(wantInstancePrefix+"/pipewire"),
				"org.chromium.Chromium",
				"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
			), sysUsesInstance(nil), nil, insertsOps(afterSpRuntimeOp(nil)), []stub.Call{
			// this op configures the container state and does not make calls during toContainer
		}, &container.Params{
			Ops: new(container.Ops).
				Bind(m(wantInstancePrefix+"/pipewire"), m("/run/user/1000/pipewire-0"), 0),
		}, paramsWantEnv(config, map[string]string{
			pipewire.Remote: "/run/user/1000/pipewire-0",
		}, nil), nil},
	})
}