...
1 package errors
2
3 import (
4 "testing"
5
6 "github.com/letsencrypt/boulder/identifier"
7 "github.com/letsencrypt/boulder/test"
8 )
9
10
11
12 func TestWithSubErrors(t *testing.T) {
13 topErr := &BoulderError{
14 Type: RateLimit,
15 Detail: "don't you think you have enough certificates already?",
16 }
17
18 subErrs := []SubBoulderError{
19 {
20 Identifier: identifier.DNSIdentifier("example.com"),
21 BoulderError: &BoulderError{
22 Type: RateLimit,
23 Detail: "everyone uses this example domain",
24 },
25 },
26 {
27 Identifier: identifier.DNSIdentifier("what about example.com"),
28 BoulderError: &BoulderError{
29 Type: RateLimit,
30 Detail: "try a real identifier value next time",
31 },
32 },
33 }
34
35 outResult := topErr.WithSubErrors(subErrs)
36
37 test.AssertNotEquals(t, topErr, outResult)
38
39 test.AssertDeepEquals(t, outResult.SubErrors, subErrs)
40
41 anotherSubErr := SubBoulderError{
42 Identifier: identifier.DNSIdentifier("another ident"),
43 BoulderError: &BoulderError{
44 Type: RateLimit,
45 Detail: "another rate limit err",
46 },
47 }
48 outResult = outResult.WithSubErrors([]SubBoulderError{anotherSubErr})
49 test.AssertDeepEquals(t, outResult.SubErrors, append(subErrs, anotherSubErr))
50 }
51
View as plain text