MCPcopy Create free account
hub / github.com/docker/cli / TestParseModes

Function TestParseModes

cli/command/container/opts_test.go:764–789  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

762}
763
764func TestParseModes(t *testing.T) {
765 // pid ko
766 flags, copts := setupRunFlags()
767 args := []string{"--pid=container:", "img", "cmd"}
768 assert.NilError(t, flags.Parse(args))
769 _, err := parse(flags, copts, runtime.GOOS)
770 assert.ErrorContains(t, err, "--pid: invalid PID mode")
771
772 // pid ok
773 _, hostconfig, _, err := parseRun([]string{"--pid=host", "img", "cmd"})
774 assert.NilError(t, err)
775 if !hostconfig.PidMode.Valid() {
776 t.Fatalf("Expected a valid PidMode, got %v", hostconfig.PidMode)
777 }
778
779 // uts ko
780 _, _, _, err = parseRun([]string{"--uts=container:", "img", "cmd"}) //nolint:dogsled
781 assert.ErrorContains(t, err, "--uts: invalid UTS mode")
782
783 // uts ok
784 _, hostconfig, _, err = parseRun([]string{"--uts=host", "img", "cmd"})
785 assert.NilError(t, err)
786 if !hostconfig.UTSMode.Valid() {
787 t.Fatalf("Expected a valid UTSMode, got %v", hostconfig.UTSMode)
788 }
789}
790
791func TestRunFlagsParseShmSize(t *testing.T) {
792 // shm-size ko

Callers

nothing calls this directly

Calls 3

setupRunFlagsFunction · 0.85
parseFunction · 0.85
parseRunFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…