(t *testing.T)
| 33 | ) |
| 34 | |
| 35 | func TestNewCmdEdit(t *testing.T) { |
| 36 | attachEvent := func(count int64) []ghtelemetry.Event { |
| 37 | return []ghtelemetry.Event{{ |
| 38 | Type: "attachment_invocation", |
| 39 | Dimensions: ghtelemetry.Dimensions{"command": "edit"}, |
| 40 | Measures: ghtelemetry.Measures{ |
| 41 | "attach_count": count, "append_ops_count": 0, "replace_ops_count": 0, |
| 42 | }, |
| 43 | }} |
| 44 | } |
| 45 | |
| 46 | tests := []struct { |
| 47 | name string |
| 48 | args string |
| 49 | ghRepo string |
| 50 | wantOpts EditOptions |
| 51 | wantAssetPaths []string |
| 52 | wantEvents []ghtelemetry.Event |
| 53 | wantRepo string |
| 54 | wantErr string |
| 55 | wantFlagErr bool |
| 56 | }{ |
| 57 | { |
| 58 | name: "--name", |
| 59 | args: "142 2 --name 'OAuth callback plan v2'", |
| 60 | wantOpts: EditOptions{ |
| 61 | IssueNumber: 142, |
| 62 | ArtifactNumber: 2, |
| 63 | Name: new("OAuth callback plan v2"), |
| 64 | }, |
| 65 | wantRepo: "OWNER/REPO", |
| 66 | }, |
| 67 | { |
| 68 | name: "a name of spaces is left to the server", |
| 69 | args: "142 2 --name ' '", |
| 70 | wantOpts: EditOptions{ |
| 71 | IssueNumber: 142, |
| 72 | ArtifactNumber: 2, |
| 73 | Name: new(" "), |
| 74 | }, |
| 75 | wantRepo: "OWNER/REPO", |
| 76 | }, |
| 77 | { |
| 78 | name: "--body", |
| 79 | args: "142 3 --body " + runbookURLv2, |
| 80 | wantOpts: EditOptions{ |
| 81 | IssueNumber: 142, |
| 82 | ArtifactNumber: 3, |
| 83 | Body: new(runbookURLv2), |
| 84 | }, |
| 85 | wantRepo: "OWNER/REPO", |
| 86 | }, |
| 87 | { |
| 88 | name: "-b is --body", |
| 89 | args: "142 2 -b '# OAuth callback plan'", |
| 90 | wantOpts: EditOptions{ |
| 91 | IssueNumber: 142, |
| 92 | ArtifactNumber: 2, |
nothing calls this directly
no test coverage detected