forked from taskcluster/generic-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos_groups_posix_test.go
More file actions
44 lines (37 loc) · 1 KB
/
os_groups_posix_test.go
File metadata and controls
44 lines (37 loc) · 1 KB
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
// +build darwin linux
package main
import (
"io/ioutil"
"path/filepath"
"strings"
"testing"
)
func TestEmptyOSGroups(t *testing.T) {
defer setup(t)()
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
OSGroups: []string{},
}
td := testTask(t)
_ = submitAndAssert(t, td, payload, "completed", "completed")
}
func TestNonEmptyOSGroups(t *testing.T) {
defer setup(t)()
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
OSGroups: []string{"abc"},
}
td := testTask(t)
_ = submitAndAssert(t, td, payload, "exception", "malformed-payload")
// check log mentions issue
bytes, err := ioutil.ReadFile(filepath.Join(taskContext.TaskDir, logPath))
if err != nil {
t.Fatalf("Error when trying to read log file: %v", err)
}
logtext := string(bytes)
if !strings.Contains(logtext, "- osGroups: Array must have at most 0 items") {
t.Fatalf("Was expecting log file to contain '- osGroups: Array must have at most 0 items' but it doesn't")
}
}