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

Function assertCatHelper

cmd/nerdctl/container/container_cp_linux_test.go:810–831  ·  view source on GitHub ↗
(base *testutil.Base, catPath string, fileContent []byte, container string, expectedUID int, containerIsStopped bool)

Source from the content-addressed store, hash-verified

808}
809
810func assertCatHelper(base *testutil.Base, catPath string, fileContent []byte, container string, expectedUID int, containerIsStopped bool) {
811 base.T.Logf("catPath=%q", catPath)
812 if container != "" && containerIsStopped {
813 base.Cmd("start", container).AssertOK()
814 defer base.Cmd("stop", container).AssertOK()
815 }
816
817 if container == "" {
818 got, err := os.ReadFile(catPath)
819 assert.NilError(base.T, err, "Failed reading from file")
820 assert.DeepEqual(base.T, fileContent, got)
821 st, err := os.Stat(catPath)
822 assert.NilError(base.T, err)
823 stSys := st.Sys().(*syscall.Stat_t)
824 expected := uint32(expectedUID)
825 actual := stSys.Uid
826 assert.DeepEqual(base.T, expected, actual)
827 } else {
828 base.Cmd("exec", container, "sh", "-c", "--", fmt.Sprintf("ls -lA /; echo %q; cat %q", catPath, catPath)).AssertOutContains(string(fileContent))
829 base.Cmd("exec", container, "stat", "-c", "%u", catPath).AssertOutExactly(fmt.Sprintf("%d\n", expectedUID))
830 }
831}
832
833func cpTestHelper(t *testing.T, tg *testgroup) {
834 // Get the source path

Callers 1

cpTestHelperFunction · 0.85

Calls 5

AssertOKMethod · 0.80
StatMethod · 0.80
AssertOutContainsMethod · 0.80
AssertOutExactlyMethod · 0.80
CmdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…