(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func TestFormat(t *testing.T) { |
| 71 | tt := testutils.T{t} |
| 72 | |
| 73 | baseErr := errors.New("woo") |
| 74 | const woo = `woo` |
| 75 | const waawoo = `waa: woo` |
| 76 | // rm is what's left over after redaction. |
| 77 | rm := string(redact.RedactableBytes(redact.RedactedMarker()).StripMarkers()) |
| 78 | |
| 79 | testCases := []struct { |
| 80 | name string |
| 81 | err error |
| 82 | expFmtSimple string |
| 83 | expFmtVerbose string |
| 84 | details string |
| 85 | }{ |
| 86 | {"safe onearg", |
| 87 | safedetails.WithSafeDetails(baseErr, "a"), |
| 88 | woo, ` |
| 89 | woo |
| 90 | (1) a |
| 91 | Wraps: (2) woo |
| 92 | Error types: (1) *safedetails.withSafeDetails (2) *errors.errorString`, |
| 93 | // Payload |
| 94 | `payload 0 |
| 95 | (0) a |
| 96 | payload 1 |
| 97 | (empty) |
| 98 | `}, |
| 99 | |
| 100 | {"safe empty", |
| 101 | safedetails.WithSafeDetails(baseErr, ""), |
| 102 | woo, ` |
| 103 | woo |
| 104 | (1) woo |
| 105 | Error types: (1) *errors.errorString`, |
| 106 | // Payload |
| 107 | `payload 0 |
| 108 | (empty) |
| 109 | `}, |
| 110 | |
| 111 | {"safe nofmt+onearg", |
| 112 | safedetails.WithSafeDetails(baseErr, "%v", 123), |
| 113 | woo, ` |
| 114 | woo |
| 115 | (1) ` + rm + ` |
| 116 | Wraps: (2) woo |
| 117 | Error types: (1) *safedetails.withSafeDetails (2) *errors.errorString`, |
| 118 | // Payload |
| 119 | `payload 0 |
| 120 | (0) ` + rm + ` |
| 121 | payload 1 |
| 122 | (empty) |
| 123 | `}, |
| 124 | |
| 125 | {"safe err", |
| 126 | safedetails.WithSafeDetails(baseErr, "prefix: %v", |
| 127 | &os.PathError{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…