(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestNewCmdImport(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | cli string |
| 28 | tty bool |
| 29 | wants ImportOptions |
| 30 | wantsError string |
| 31 | }{ |
| 32 | { |
| 33 | name: "no filename and stdin tty", |
| 34 | cli: "", |
| 35 | tty: true, |
| 36 | wants: ImportOptions{ |
| 37 | Filename: "", |
| 38 | OverwriteExisting: false, |
| 39 | }, |
| 40 | wantsError: "no filename passed and nothing on STDIN", |
| 41 | }, |
| 42 | { |
| 43 | name: "no filename and stdin is not tty", |
| 44 | cli: "", |
| 45 | tty: false, |
| 46 | wants: ImportOptions{ |
| 47 | Filename: "-", |
| 48 | OverwriteExisting: false, |
| 49 | }, |
| 50 | }, |
| 51 | { |
| 52 | name: "stdin arg", |
| 53 | cli: "-", |
| 54 | wants: ImportOptions{ |
| 55 | Filename: "-", |
| 56 | OverwriteExisting: false, |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | name: "multiple filenames", |
| 61 | cli: "aliases1 aliases2", |
| 62 | wants: ImportOptions{ |
| 63 | Filename: "aliases1 aliases2", |
| 64 | OverwriteExisting: false, |
| 65 | }, |
| 66 | wantsError: "too many arguments", |
| 67 | }, |
| 68 | { |
| 69 | name: "clobber flag", |
| 70 | cli: "aliases --clobber", |
| 71 | wants: ImportOptions{ |
| 72 | Filename: "aliases", |
| 73 | OverwriteExisting: true, |
| 74 | }, |
| 75 | }, |
| 76 | } |
| 77 | |
| 78 | for _, tt := range tests { |
| 79 | t.Run(tt.name, func(t *testing.T) { |
| 80 | ios, _, _, _ := iostreams.Test() |
| 81 | ios.SetStdinTTY(tt.tty) |
nothing calls this directly
no test coverage detected