(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestParsePatchHeader(t *testing.T) { |
| 75 | expectedSHA := "61f5cd90bed4d204ee3feb3aa41ee91d4734855b" |
| 76 | expectedIdentity := &PatchIdentity{ |
| 77 | Name: "Morton Haypenny", |
| 78 | Email: "mhaypenny@example.com", |
| 79 | } |
| 80 | expectedDate := time.Date(2020, 04, 11, 15, 21, 23, 0, time.FixedZone("PDT", -7*60*60)) |
| 81 | expectedTitle := "A sample commit to test header parsing" |
| 82 | expectedEmojiOneLineTitle := "🤖 Enabling auto-merging" |
| 83 | expectedEmojiMultiLineTitle := "[IA64] Put ia64 config files on the Uwe Kleine-König diet" |
| 84 | expectedBody := "The medium format shows the body, which\nmay wrap on to multiple lines.\n\nAnother body line." |
| 85 | expectedBodyAppendix := "CC: Joe Smith <joe.smith@company.com>" |
| 86 | |
| 87 | tests := map[string]struct { |
| 88 | Input string |
| 89 | Options []PatchHeaderOption |
| 90 | Header PatchHeader |
| 91 | Err interface{} |
| 92 | }{ |
| 93 | "prettyShort": { |
| 94 | Input: `commit 61f5cd90bed4d204ee3feb3aa41ee91d4734855b |
| 95 | Author: Morton Haypenny <mhaypenny@example.com> |
| 96 | |
| 97 | A sample commit to test header parsing |
| 98 | `, |
| 99 | Header: PatchHeader{ |
| 100 | SHA: expectedSHA, |
| 101 | Author: expectedIdentity, |
| 102 | Title: expectedTitle, |
| 103 | }, |
| 104 | }, |
| 105 | "prettyMedium": { |
| 106 | Input: `commit 61f5cd90bed4d204ee3feb3aa41ee91d4734855b |
| 107 | Author: Morton Haypenny <mhaypenny@example.com> |
| 108 | Date: Sat Apr 11 15:21:23 2020 -0700 |
| 109 | |
| 110 | A sample commit to test header parsing |
| 111 | |
| 112 | The medium format shows the body, which |
| 113 | may wrap on to multiple lines. |
| 114 | |
| 115 | Another body line. |
| 116 | `, |
| 117 | Header: PatchHeader{ |
| 118 | SHA: expectedSHA, |
| 119 | Author: expectedIdentity, |
| 120 | AuthorDate: expectedDate, |
| 121 | Title: expectedTitle, |
| 122 | Body: expectedBody, |
| 123 | }, |
| 124 | }, |
| 125 | "prettyFull": { |
| 126 | Input: `commit 61f5cd90bed4d204ee3feb3aa41ee91d4734855b |
| 127 | Author: Morton Haypenny <mhaypenny@example.com> |
| 128 | Commit: Morton Haypenny <mhaypenny@example.com> |
| 129 | |
| 130 | A sample commit to test header parsing |
| 131 |
nothing calls this directly
no test coverage detected