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

Function TestCopyToContainer

cmd/nerdctl/container/container_cp_linux_test.go:93–455  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestCopyToContainer(t *testing.T) {
94 t.Parallel()
95
96 testGroups := []*testgroup{
97 {
98 description: "Copying to container, SRC_PATH is a file, absolute",
99 sourceSpec: filepath.Join(string(os.PathSeparator), srcDirName, srcFileName),
100 sourceIsAFile: true,
101 toContainer: true,
102 testCases: []testcases{
103 {
104 description: "DEST_PATH does not exist, relative",
105 destinationSpec: pathDoesNotExistRelative,
106 expect: icmd.Expected{
107 ExitCode: 0,
108 },
109 },
110 {
111 description: "DEST_PATH does not exist, absolute",
112 destinationSpec: pathDoesNotExistAbsolute,
113 expect: icmd.Expected{
114 ExitCode: 0,
115 },
116 },
117 {
118 description: "DEST_PATH does not exist, relative, and ends with " + string(os.PathSeparator),
119 destinationSpec: pathDoesNotExistRelative + string(os.PathSeparator),
120 expect: icmd.Expected{
121 ExitCode: 1,
122 Err: containerutil.ErrDestinationDirMustExist.Error(),
123 },
124 },
125 {
126 description: "DEST_PATH does not exist, absolute, and ends with " + string(os.PathSeparator),
127 destinationSpec: pathDoesNotExistAbsolute + string(os.PathSeparator),
128 expect: icmd.Expected{
129 ExitCode: 1,
130 Err: containerutil.ErrDestinationDirMustExist.Error(),
131 },
132 },
133
134 {
135 description: "DEST_PATH is a file, relative",
136 destinationSpec: pathIsAFileRelative,
137 expect: icmd.Expected{
138 ExitCode: 0,
139 },
140 setup: func(base *testutil.Base, container string, destPath string) {
141 base.Cmd("exec", container, "touch", destPath).AssertOK()
142 },
143 },
144 {
145 description: "DEST_PATH is a file, absolute",
146 destinationSpec: pathIsAFileAbsolute,
147 expect: icmd.Expected{
148 ExitCode: 0,
149 },
150 setup: func(base *testutil.Base, container string, destPath string) {

Callers

nothing calls this directly

Calls 5

cpTestHelperFunction · 0.85
AssertOKMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45
CmdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…