-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimits_test.go
More file actions
36 lines (28 loc) · 787 Bytes
/
Copy pathlimits_test.go
File metadata and controls
36 lines (28 loc) · 787 Bytes
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
package trexec_test
import (
"context"
"testing"
"time"
"github.com/Chokqu/trexec"
)
func TestWithResourceLimits(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
limits := trexec.ResourceLimits{
MaxMemoryBytes: 256 * 1024 * 1024, // 256 MB
MaxProcesses: 10,
}
cmd := trexec.CommandContext(ctx, helperBin, []string{"-stdout=limits test"},
trexec.WithResourceLimits(limits),
)
out, result, err := cmd.Output()
if err != nil {
t.Fatalf("command execution with resource limits failed: %v", err)
}
if !result.Success() {
t.Errorf("expected success with valid resource limits, got: %s", result)
}
if string(out) != "limits test\n" {
t.Errorf("output = %q, want %q", string(out), "limits test\n")
}
}