(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func TestEnvAdd(t *testing.T) { |
| 356 | t.Setenv("FOO", "BAR") |
| 357 | t.Setenv("BLED", "BLED") |
| 358 | t.Setenv("BAZ", "OLD") |
| 359 | |
| 360 | command := &com.Command{ |
| 361 | Binary: "env", |
| 362 | Env: map[string]string{ |
| 363 | "FOO": "REPLACE", |
| 364 | "BAR": "NEW", |
| 365 | "BLED": "EXPLICIT", |
| 366 | }, |
| 367 | EnvBlackList: []string{ |
| 368 | "LS_COLORS", |
| 369 | "BLED", |
| 370 | }, |
| 371 | } |
| 372 | |
| 373 | err := command.Run(context.WithValue(context.Background(), com.LoggerKey, t)) |
| 374 | |
| 375 | assertive.ErrorIsNil(t, err, "Err") |
| 376 | |
| 377 | res, err := command.Wait() |
| 378 | |
| 379 | assertive.ErrorIsNil(t, err, "Err") |
| 380 | assertive.IsEqual(t, res.ExitCode, 0, "ExitCode") |
| 381 | // Confirm explicit Env: declaration overrides os.Environ |
| 382 | assertive.Contains(t, res.Stdout, "FOO=REPLACE", "Stdout") |
| 383 | // Confirm explicit Env: declaration does add a new variable |
| 384 | assertive.Contains(t, res.Stdout, "BAR=NEW", "Stdout") |
| 385 | // Confirm explicit Env: declaration for unrelated variable does not reset os.Environ |
| 386 | assertive.Contains(t, res.Stdout, "BAZ=OLD", "Stdout") |
| 387 | // Confirm that blacklist only operates on os.Environ and not on any explicitly added Env: declaration |
| 388 | assertive.Contains(t, res.Stdout, "BLED=EXPLICIT", "Stdout") |
| 389 | } |
| 390 | |
| 391 | func TestStdoutStderr(t *testing.T) { |
| 392 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…