carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux
2
3package host
4
5import "testing"
6
7func TestPlan14GenerationServiceSupervisor(t *testing.T) {
8 for _, tc := range []struct {
9 name, unit, group, status string
10 main int
11 want bool
12 }{
13 {"main", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\n", 42, true},
14 {"other process", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t43\n", 42, false},
15 {"child group", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise/child", "Tgid:\t42\n", 42, false},
16 {"other service", "unknown.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\n", 42, false},
17 {"missing main", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t0\n", 0, false},
18 {"missing identity", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Uid:\t999\n", 42, false},
19 {"duplicate", "carlos-edge.service", "/carlos.slice/carlos-edge.service/supervise", "Tgid:\t42\nTgid:\t42\n", 42, false},
20 } {
21 t.Run(tc.name, func(t *testing.T) {
22 if got := generationServiceSupervisor(tc.unit, tc.group, "/carlos.slice/carlos-edge.service", []byte(tc.status), tc.main); got != tc.want {
23 t.Fatal(got)
24 }
25 })
26 }
27}
28