MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestRunHostnameEnv

Function TestRunHostnameEnv

cmd/nerdctl/container/container_run_test.go:264–288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

262}
263
264func 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
290func TestRunStdin(t *testing.T) {
291 testCase := nerdtest.Setup()

Callers

nothing calls this directly

Calls 4

SetupFunction · 0.92
CommandMethod · 0.65
FeedMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…