(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestDeleteRun(t *testing.T) { |
| 85 | tests := []struct { |
| 86 | name string |
| 87 | tty bool |
| 88 | opts *deleteOptions |
| 89 | httpStubs func(*httpmock.Registry) |
| 90 | prompterStubs func(*prompter.PrompterMock) |
| 91 | wantStdout string |
| 92 | wantErr bool |
| 93 | errMsg string |
| 94 | }{ |
| 95 | { |
| 96 | name: "deletes label", |
| 97 | tty: true, |
| 98 | opts: &deleteOptions{Name: "test"}, |
| 99 | httpStubs: func(reg *httpmock.Registry) { |
| 100 | reg.Register( |
| 101 | httpmock.REST("DELETE", "repos/OWNER/REPO/labels/test"), |
| 102 | httpmock.StatusStringResponse(204, "{}"), |
| 103 | ) |
| 104 | }, |
| 105 | prompterStubs: func(pm *prompter.PrompterMock) { |
| 106 | pm.ConfirmDeletionFunc = func(_ string) error { |
| 107 | return nil |
| 108 | } |
| 109 | }, |
| 110 | wantStdout: "✓ Label \"test\" deleted from OWNER/REPO\n", |
| 111 | }, |
| 112 | { |
| 113 | name: "deletes label notty", |
| 114 | tty: false, |
| 115 | opts: &deleteOptions{Name: "test", Confirmed: true}, |
| 116 | httpStubs: func(reg *httpmock.Registry) { |
| 117 | reg.Register( |
| 118 | httpmock.REST("DELETE", "repos/OWNER/REPO/labels/test"), |
| 119 | httpmock.StatusStringResponse(204, "{}"), |
| 120 | ) |
| 121 | }, |
| 122 | wantStdout: "", |
| 123 | }, |
| 124 | { |
| 125 | name: "missing label", |
| 126 | tty: false, |
| 127 | opts: &deleteOptions{Name: "missing", Confirmed: true}, |
| 128 | httpStubs: func(reg *httpmock.Registry) { |
| 129 | reg.Register( |
| 130 | httpmock.REST("DELETE", "repos/OWNER/REPO/labels/missing"), |
| 131 | httpmock.WithHeader( |
| 132 | httpmock.StatusStringResponse(422, ` |
| 133 | { |
| 134 | "message":"Not Found" |
| 135 | }`), |
| 136 | "Content-Type", |
| 137 | "application/json", |
| 138 | ), |
| 139 | ) |
| 140 | }, |
| 141 | wantErr: true, |
nothing calls this directly
no test coverage detected