MCPcopy
hub / github.com/air-verse/air / TestConfigWithRuntimeArgs

Function TestConfigWithRuntimeArgs

runner/config_test.go:254–288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

252}
253
254func 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
290func TestReadConfigWithWrongPath(t *testing.T) {
291 t.Parallel()

Callers

nothing calls this directly

Calls 4

defaultConfigFunction · 0.85
containsFunction · 0.85
preprocessMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…