(t *testing.T)
| 33 | ) |
| 34 | |
| 35 | func TestNewCmdCreate(t *testing.T) { |
| 36 | attachEvent := func(count int64) []ghtelemetry.Event { |
| 37 | return []ghtelemetry.Event{{ |
| 38 | Type: "attachment_invocation", |
| 39 | Dimensions: ghtelemetry.Dimensions{"command": "create"}, |
| 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 | // alias runs the command through a parent by this name, such as add. |
| 49 | alias string |
| 50 | args string |
| 51 | ghRepo string |
| 52 | wantOpts CreateOptions |
| 53 | wantAssetPaths []string |
| 54 | wantEvents []ghtelemetry.Event |
| 55 | wantRepo string |
| 56 | wantErr string |
| 57 | wantFlagErr bool |
| 58 | }{ |
| 59 | { |
| 60 | name: "a file", |
| 61 | args: "142 signin-plan.md", |
| 62 | wantOpts: CreateOptions{ |
| 63 | IssueNumber: 142, |
| 64 | Sources: []source{{kind: fromFile, arg: "signin-plan.md"}}, |
| 65 | }, |
| 66 | wantRepo: "OWNER/REPO", |
| 67 | }, |
| 68 | { |
| 69 | name: "a name after #", |
| 70 | args: "142 'docs/signin-plan.md#Sign-in plan'", |
| 71 | wantOpts: CreateOptions{ |
| 72 | IssueNumber: 142, |
| 73 | Sources: []source{{kind: fromFile, arg: "docs/signin-plan.md", name: "Sign-in plan"}}, |
| 74 | }, |
| 75 | wantRepo: "OWNER/REPO", |
| 76 | }, |
| 77 | { |
| 78 | name: "a file whose name contains # stays whole, and a name can follow it", |
| 79 | args: "142 'barista-notes#2.md' 'barista-notes#2.md#Barista notes round 2'", |
| 80 | wantOpts: CreateOptions{ |
| 81 | IssueNumber: 142, |
| 82 | Sources: []source{ |
| 83 | {kind: fromFile, arg: "barista-notes#2.md"}, |
| 84 | {kind: fromFile, arg: "barista-notes#2.md", name: "Barista notes round 2"}, |
| 85 | }, |
| 86 | }, |
| 87 | wantRepo: "OWNER/REPO", |
| 88 | }, |
| 89 | { |
| 90 | name: "a name can contain #", |
| 91 | args: "142 'signin-plan.md#Plan #2'", |
| 92 | wantOpts: CreateOptions{ |
nothing calls this directly
no test coverage detected