(t *testing.T)
| 97 | } |
| 98 | |
| 99 | func TestCommandEnvironment(t *testing.T) { |
| 100 | const expect = "message from environment\n" |
| 101 | ctx := log.Testing(t) |
| 102 | buf := &bytes.Buffer{} |
| 103 | env := shell.NewEnv().Set("MESSAGE", "message from environment") |
| 104 | err := shell.Command("printenv", "MESSAGE"). |
| 105 | Capture(buf, nil). |
| 106 | Env(env). |
| 107 | Run(ctx) |
| 108 | assert.For(ctx, "err").ThatError(err).Succeeded() |
| 109 | assert.For(ctx, "buf").ThatString(buf).Equals(expect) |
| 110 | } |
| 111 | |
| 112 | type errorTarget struct{} |
| 113 |