(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestAliasList(t *testing.T) { |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | config string |
| 21 | isTTY bool |
| 22 | wantErr bool |
| 23 | wantStdout string |
| 24 | wantStderr string |
| 25 | }{ |
| 26 | { |
| 27 | name: "empty", |
| 28 | config: "", |
| 29 | isTTY: true, |
| 30 | wantErr: true, |
| 31 | wantStdout: "", |
| 32 | wantStderr: "", |
| 33 | }, |
| 34 | { |
| 35 | name: "some", |
| 36 | config: heredoc.Doc(` |
| 37 | aliases: |
| 38 | co: pr checkout |
| 39 | gc: "!gh gist create \"$@\" | pbcopy" |
| 40 | `), |
| 41 | isTTY: true, |
| 42 | wantStdout: "co: pr checkout\ngc: '!gh gist create \"$@\" | pbcopy'\n", |
| 43 | wantStderr: "", |
| 44 | }, |
| 45 | { |
| 46 | name: "multiline", |
| 47 | config: heredoc.Doc(` |
| 48 | aliases: |
| 49 | one: "foo\nbar\n" |
| 50 | two: |- |
| 51 | !chicken |
| 52 | coop |
| 53 | `), |
| 54 | isTTY: true, |
| 55 | wantStdout: "one: |\n foo\n bar\ntwo: |-\n !chicken\n coop\n", |
| 56 | wantStderr: "", |
| 57 | }, |
| 58 | } |
| 59 | for _, tt := range tests { |
| 60 | t.Run(tt.name, func(t *testing.T) { |
| 61 | cfg := config.NewFromString(tt.config) |
| 62 | |
| 63 | ios, _, stdout, stderr := iostreams.Test() |
| 64 | ios.SetStdoutTTY(tt.isTTY) |
| 65 | ios.SetStdinTTY(tt.isTTY) |
| 66 | ios.SetStderrTTY(tt.isTTY) |
| 67 | |
| 68 | factory := &cmdutil.Factory{ |
| 69 | IOStreams: ios, |
| 70 | Config: func() (gh.Config, error) { |
| 71 | return cfg, nil |
| 72 | }, |
| 73 | } |
| 74 |
nothing calls this directly
no test coverage detected