(t *testing.T)
| 61 | } |
| 62 | |
| 63 | func TestFormatUnimp(t *testing.T) { |
| 64 | tt := testutils.T{t} |
| 65 | |
| 66 | link := issuelink.IssueLink{IssueURL: "http://mysite"} |
| 67 | const woo = `woo` |
| 68 | const waawoo = `waa: woo` |
| 69 | testCases := []struct { |
| 70 | name string |
| 71 | err error |
| 72 | expFmtSimple string |
| 73 | expFmtVerbose string |
| 74 | }{ |
| 75 | {"unimp", |
| 76 | issuelink.UnimplementedError(link, "woo"), |
| 77 | woo, ` |
| 78 | woo |
| 79 | (1) woo |
| 80 | | unimplemented |
| 81 | | issue: http://mysite |
| 82 | Error types: (1) *issuelink.unimplementedError`}, |
| 83 | {"unimp-details", |
| 84 | issuelink.UnimplementedError(issuelink.IssueLink{IssueURL: "http://mysite", Detail: "see more"}, "woo"), |
| 85 | woo, ` |
| 86 | woo |
| 87 | (1) woo |
| 88 | | unimplemented |
| 89 | | issue: http://mysite |
| 90 | | detail: see more |
| 91 | Error types: (1) *issuelink.unimplementedError`}, |
| 92 | |
| 93 | {"wrapper + unimp", |
| 94 | &werrFmt{issuelink.UnimplementedError(link, "woo"), "waa"}, |
| 95 | waawoo, ` |
| 96 | waa: woo |
| 97 | (1) waa |
| 98 | | -- this is waa's |
| 99 | | multi-line payload |
| 100 | Wraps: (2) woo |
| 101 | | unimplemented |
| 102 | | issue: http://mysite |
| 103 | Error types: (1) *issuelink_test.werrFmt (2) *issuelink.unimplementedError`}, |
| 104 | } |
| 105 | |
| 106 | for _, test := range testCases { |
| 107 | tt.Run(test.name, func(tt testutils.T) { |
| 108 | err := test.err |
| 109 | |
| 110 | // %s is simple formatting |
| 111 | tt.CheckStringEqual(fmt.Sprintf("%s", err), test.expFmtSimple) |
| 112 | |
| 113 | // %v is simple formatting too, for compatibility with the past. |
| 114 | tt.CheckStringEqual(fmt.Sprintf("%v", err), test.expFmtSimple) |
| 115 | |
| 116 | // %q is always like %s but quotes the result. |
| 117 | ref := fmt.Sprintf("%q", test.expFmtSimple) |
| 118 | tt.CheckStringEqual(fmt.Sprintf("%q", err), ref) |
| 119 | |
| 120 | // %+v is the verbose mode. |
nothing calls this directly
no test coverage detected
searching dependent graphs…