| 262 | } |
| 263 | |
| 264 | func TestRunHostnameEnv(t *testing.T) { |
| 265 | testCase := nerdtest.Setup() |
| 266 | |
| 267 | testCase.SubTests = []*test.Case{ |
| 268 | { |
| 269 | Description: "default hostname", |
| 270 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 271 | cmd := helpers.Command("run", "--rm", "--quiet", testutil.CommonImage) |
| 272 | // Note: on Windows, just straight passing the command will not work (some cmd escaping weirdness?) |
| 273 | cmd.Feed(strings.NewReader(`[[ "HOSTNAME=$(hostname)" == "$(env | grep HOSTNAME)" ]]`)) |
| 274 | return cmd |
| 275 | }, |
| 276 | Expected: test.Expects(expect.ExitCodeSuccess, nil, nil), |
| 277 | }, |
| 278 | { |
| 279 | Description: "with --hostname", |
| 280 | // Windows does not support --hostname |
| 281 | Require: require.Not(require.Windows), |
| 282 | Command: test.Command("run", "--rm", "--quiet", "--hostname", "foobar", testutil.CommonImage, "env"), |
| 283 | Expected: test.Expects(expect.ExitCodeSuccess, nil, expect.Contains("HOSTNAME=foobar")), |
| 284 | }, |
| 285 | } |
| 286 | |
| 287 | testCase.Run(t) |
| 288 | } |
| 289 | |
| 290 | func TestRunStdin(t *testing.T) { |
| 291 | testCase := nerdtest.Setup() |