(t *testing.T)
| 252 | } |
| 253 | |
| 254 | func TestConfigWithRuntimeArgs(t *testing.T) { |
| 255 | runtimeArg := "-flag=value" |
| 256 | |
| 257 | // inject runtime arg |
| 258 | oldArgs := os.Args |
| 259 | defer func() { |
| 260 | os.Args = oldArgs |
| 261 | flag.Parse() |
| 262 | }() |
| 263 | os.Args = []string{"air", "--", runtimeArg} |
| 264 | flag.Parse() |
| 265 | |
| 266 | t.Run("when using bin", func(t *testing.T) { |
| 267 | df := defaultConfig() |
| 268 | if err := df.preprocess(nil); err != nil { |
| 269 | t.Fatalf("preprocess error %v", err) |
| 270 | } |
| 271 | |
| 272 | if !contains(df.Build.ArgsBin, runtimeArg) { |
| 273 | t.Fatalf("missing expected runtime arg: %s", runtimeArg) |
| 274 | } |
| 275 | }) |
| 276 | |
| 277 | t.Run("when using full_bin", func(t *testing.T) { |
| 278 | df := defaultConfig() |
| 279 | df.Build.FullBin = "./tmp/main" |
| 280 | if err := df.preprocess(nil); err != nil { |
| 281 | t.Fatalf("preprocess error %v", err) |
| 282 | } |
| 283 | |
| 284 | if !contains(df.Build.ArgsBin, runtimeArg) { |
| 285 | t.Fatalf("missing expected runtime arg: %s", runtimeArg) |
| 286 | } |
| 287 | }) |
| 288 | } |
| 289 | |
| 290 | func TestReadConfigWithWrongPath(t *testing.T) { |
| 291 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…