Download this file
| 1 | package hostfloor |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestConsoleGuardDropInStartsServe(t *testing.T) { |
| 10 | const path = "/opt/carlos/console/current/console" |
| 11 | body := ConsoleGuardDropIn(path) |
| 12 | prefix := "[Service]\nExecStart=\nExecStart=" |
| 13 | if !strings.HasPrefix(body, prefix) { |
| 14 | t.Fatalf("drop-in does not reset ExecStart: %q", body) |
| 15 | } |
| 16 | args := strings.Fields(strings.TrimPrefix(body, prefix)) |
| 17 | want := []string{"/opt/carlos/system/guard/carlos", "system", "guard-exec", "console", path, "serve"} |
| 18 | if !reflect.DeepEqual(args, want) { |
| 19 | t.Fatalf("guarded console invocation = %q, want %q", args, want) |
| 20 | } |
| 21 | } |
| 22 | |