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

Function TestRunAttachFlag

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

Source from the content-addressed store, hash-verified

695}
696
697func TestRunAttachFlag(t *testing.T) {
698 testCase := nerdtest.Setup()
699 testCase.Require = require.Not(require.Windows)
700
701 type attachTC struct {
702 description string
703 args []string
704 useStdin bool
705 isError bool
706 testStr string
707 expectedOut string
708 dockerOut string
709 }
710
711 tcs := []attachTC{
712 {
713 description: "AttachFlagStdin",
714 args: []string{"-a", "STDIN", "-a", "STDOUT"},
715 useStdin: true,
716 testStr: "test-run-stdio",
717 expectedOut: "test-run-stdio",
718 dockerOut: "test-run-stdio",
719 },
720 {
721 description: "AttachFlagStdOut",
722 args: []string{"-a", "STDOUT"},
723 testStr: "foo",
724 expectedOut: "foo",
725 dockerOut: "foo",
726 },
727 {
728 description: "AttachFlagMixedValue",
729 args: []string{"-a", "STDIN", "-a", "invalid-value"},
730 isError: true,
731 testStr: "foo",
732 expectedOut: "invalid stream specified with -a flag. Valid streams are STDIN, STDOUT, and STDERR",
733 dockerOut: "valid streams are STDIN, STDOUT and STDERR",
734 },
735 {
736 description: "AttachFlagInvalidValue",
737 args: []string{"-a", "invalid-stream"},
738 isError: true,
739 testStr: "foo",
740 expectedOut: "invalid stream specified with -a flag. Valid streams are STDIN, STDOUT, and STDERR",
741 dockerOut: "valid streams are STDIN, STDOUT and STDERR",
742 },
743 {
744 description: "AttachFlagCaseInsensitive",
745 args: []string{"-a", "stdin", "-a", "stdout"},
746 useStdin: true,
747 testStr: "test-run-stdio",
748 expectedOut: "test-run-stdio",
749 dockerOut: "test-run-stdio",
750 },
751 }
752
753 for _, tc := range tcs {
754 testCase.SubTests = append(testCase.SubTests, &test.Case{

Callers

nothing calls this directly

Calls 7

SetupFunction · 0.92
IsDockerFunction · 0.92
AnyhowMethod · 0.65
IdentifierMethod · 0.65
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…