| 81 | } |
| 82 | |
| 83 | func TestOSCommandFileType(t *testing.T) { |
| 84 | type scenario struct { |
| 85 | path string |
| 86 | setup func() |
| 87 | test func(string) |
| 88 | } |
| 89 | |
| 90 | scenarios := []scenario{ |
| 91 | { |
| 92 | "testFile", |
| 93 | func() { |
| 94 | f, err := os.Create("testFile") |
| 95 | if err != nil { |
| 96 | panic(err) |
| 97 | } |
| 98 | if err := f.Close(); err != nil { |
| 99 | panic(err) |
| 100 | } |
| 101 | }, |
| 102 | func(output string) { |
| 103 | assert.EqualValues(t, "file", output) |
| 104 | }, |
| 105 | }, |
| 106 | { |
| 107 | "file with spaces", |
| 108 | func() { |
| 109 | f, err := os.Create("file with spaces") |
| 110 | if err != nil { |
| 111 | panic(err) |
| 112 | } |
| 113 | if err := f.Close(); err != nil { |
| 114 | panic(err) |
| 115 | } |
| 116 | }, |
| 117 | func(output string) { |
| 118 | assert.EqualValues(t, "file", output) |
| 119 | }, |
| 120 | }, |
| 121 | { |
| 122 | "testDirectory", |
| 123 | func() { |
| 124 | if err := os.Mkdir("testDirectory", 0o644); err != nil { |
| 125 | panic(err) |
| 126 | } |
| 127 | }, |
| 128 | func(output string) { |
| 129 | assert.EqualValues(t, "directory", output) |
| 130 | }, |
| 131 | }, |
| 132 | { |
| 133 | "nonExistent", |
| 134 | func() {}, |
| 135 | func(output string) { |
| 136 | assert.EqualValues(t, "other", output) |
| 137 | }, |
| 138 | }, |
| 139 | } |
| 140 | |