//go:build linux package host import ( "strings" "testing" ) func TestGenerationGuardEdgeStart(t *testing.T) { const start = "{ path=/opt/carlos/system/guard/carlos ; argv[]=/opt/carlos/system/guard/carlos system guard-exec edge ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=10 ; code=(null) ; status=0/0 }" if !generationGuardEdgeStart("carlos-edge.service", start) { t.Fatal("supported guard invocation refused") } for _, other := range []string{ strings.Replace(start, "guard-exec edge", "guard-exec recover", 1), strings.Replace(start, "guard-exec edge", "guard-exec edge extra", 1), strings.Replace(start, "argv[]=/opt/carlos/system/guard/carlos", "argv[]=other", 1), strings.Replace(start, "path=/opt/carlos/system/guard/carlos", "path=/opt/carlos/carlos", 1), strings.Replace(start, "ignore_errors=no", "ignore_errors=yes", 1), start + " " + start, } { if generationGuardEdgeStart("carlos-edge.service", other) { t.Fatal("unsupported invocation accepted", other) } } if generationGuardEdgeStart("another.service", start) { t.Fatal("another unit accepted") } }