-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
45 lines (42 loc) · 1.1 KB
/
Copy patherrors_test.go
File metadata and controls
45 lines (42 loc) · 1.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
45
package acpruntime
import (
"errors"
"strings"
"testing"
)
func TestRuntimeErrorErrorIncludesSessionAndCleanup(t *testing.T) {
err := &RuntimeError{
Kind: ErrorInitialConfig,
Op: "session.initial_config",
Msg: "failed to apply initial config",
Cause: errors.New("unknown mode"),
SessionID: "sess-1",
CleanupStatus: CleanupSucceeded,
}
got := err.Error()
for _, want := range []string{
"session.initial_config",
"failed to apply initial config",
"unknown mode",
"session_id=sess-1",
"cleanup=succeeded",
} {
if !strings.Contains(got, want) {
t.Fatalf("Error() = %q, want substring %q", got, want)
}
}
}
func TestRuntimeErrorErrorIncludesCleanupError(t *testing.T) {
err := &RuntimeError{
Kind: ErrorInitialConfig,
Op: "session.initial_config",
Msg: "failed",
SessionID: "sess-2",
CleanupStatus: CleanupFailed,
CleanupError: errors.New("delete refused"),
}
got := err.Error()
if !strings.Contains(got, "cleanup_error=delete refused") {
t.Fatalf("Error() = %q, want cleanup_error", got)
}
}