aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/system/op_test.go
blob: 50f260ad4879292b7d3396abbb2f9314f1d0d90d (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
50
51
52
53
package system_test

import (
	"strconv"
	"testing"

	"git.ophivana.moe/security/fortify/internal/system"
)

func TestNew(t *testing.T) {
	testCases := []struct {
		uid int
	}{
		{150},
		{149},
		{148},
		{147},
	}

	for _, tc := range testCases {
		t.Run("sys initialised with uid "+strconv.Itoa(tc.uid), func(t *testing.T) {
			if got := system.New(tc.uid); got.UID() != tc.uid {
				t.Errorf("New(%d) uid = %d, want %d",
					tc.uid,
					got.UID(), tc.uid)
			}
		})
	}
}

func TestTypeString(t *testing.T) {
	testCases := []struct {
		e    system.Enablement
		want string
	}{
		{system.EWayland, system.EWayland.String()},
		{system.EX11, system.EX11.String()},
		{system.EDBus, system.EDBus.String()},
		{system.EPulse, system.EPulse.String()},
		{system.User, "User"},
		{system.Process, "Process"},
	}

	for _, tc := range testCases {
		t.Run("label type string "+tc.want, func(t *testing.T) {
			if got := system.TypeString(tc.e); got != tc.want {
				t.Errorf("TypeString(%d) = %v, want %v",
					tc.e,
					got, tc.want)
			}
		})
	}
}