forked from adamlaska/boulder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
50 lines (45 loc) · 1.43 KB
/
errors_test.go
File metadata and controls
50 lines (45 loc) · 1.43 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
46
47
48
49
50
package errors
import (
"testing"
"github.com/letsencrypt/boulder/identifier"
"github.com/letsencrypt/boulder/test"
)
// TestWithSubErrors tests that a boulder error can be created by adding
// suberrors to an existing top level boulder error
func TestWithSubErrors(t *testing.T) {
topErr := &BoulderError{
Type: RateLimit,
Detail: "don't you think you have enough certificates already?",
}
subErrs := []SubBoulderError{
{
Identifier: identifier.DNSIdentifier("example.com"),
BoulderError: &BoulderError{
Type: RateLimit,
Detail: "everyone uses this example domain",
},
},
{
Identifier: identifier.DNSIdentifier("what about example.com"),
BoulderError: &BoulderError{
Type: RateLimit,
Detail: "try a real identifier value next time",
},
},
}
outResult := topErr.WithSubErrors(subErrs)
// The outResult should be a new, distinct error
test.AssertNotEquals(t, topErr, outResult)
// The outResult error should have the correct sub errors
test.AssertDeepEquals(t, outResult.SubErrors, subErrs)
// Adding another suberr shouldn't squash the original sub errors
anotherSubErr := SubBoulderError{
Identifier: identifier.DNSIdentifier("another ident"),
BoulderError: &BoulderError{
Type: RateLimit,
Detail: "another rate limit err",
},
}
outResult = outResult.WithSubErrors([]SubBoulderError{anotherSubErr})
test.AssertDeepEquals(t, outResult.SubErrors, append(subErrs, anotherSubErr))
}