mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
So upgrading don't have to be initiated manually, helping large deployments to upgrade to latest ctrld version easily.
29 lines
802 B
Go
29 lines
802 B
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func Test_ensureSystemdKillMode(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
unitFile string
|
|
wantChange bool
|
|
}{
|
|
{"no KillMode", "[Service]\nExecStart=/bin/sleep 1", true},
|
|
{"not KillMode=process", "[Service]\nExecStart=/bin/sleep 1\nKillMode=mixed", true},
|
|
{"KillMode=process", "[Service]\nExecStart=/bin/sleep 1\nKillMode=process", false},
|
|
{"invalid unit file", "[Service\nExecStart=/bin/sleep 1\nKillMode=process", false},
|
|
}
|
|
for _, tc := range tests {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
if _, change := ensureSystemdKillMode(strings.NewReader(tc.unitFile)); tc.wantChange != change {
|
|
t.Errorf("ensureSystemdKillMode(%q) = %v, want %v", tc.unitFile, change, tc.wantChange)
|
|
}
|
|
})
|
|
}
|
|
}
|