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

Function TestRunFromOCIArchive

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

Source from the content-addressed store, hash-verified

834}
835
836func TestRunFromOCIArchive(t *testing.T) {
837 testCase := nerdtest.Setup()
838 testCase.Require = require.All(nerdtest.Build, require.Not(nerdtest.Docker))
839
840 const sentinel = "test-nerdctl-run-from-oci-archive"
841
842 testCase.Setup = func(data test.Data, helpers test.Helpers) {
843 tag := fmt.Sprintf("%s:latest", data.Identifier())
844 helpers.Anyhow("rmi", "-f", tag)
845
846 dockerfile := fmt.Sprintf("FROM %s\nCMD [\"echo\", \"%s\"]", testutil.CommonImage, sentinel)
847 data.Temp().Save(dockerfile, "Dockerfile")
848 tarPath := data.Temp().Path(data.Identifier() + ".tar")
849 helpers.Ensure("build", "--tag", tag, fmt.Sprintf("--output=type=oci,dest=%s", tarPath), data.Temp().Path())
850 data.Labels().Set("tag", tag)
851 data.Labels().Set("tarPath", tarPath)
852 }
853
854 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
855 helpers.Anyhow("rmi", "-f", data.Labels().Get("tag"))
856 helpers.Anyhow("builder", "prune", "--all", "--force")
857 }
858
859 testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
860 return helpers.Command("run", "--rm", fmt.Sprintf("oci-archive://%s", data.Labels().Get("tarPath")))
861 }
862
863 testCase.Expected = test.Expects(expect.ExitCodeSuccess, nil, expect.Contains(sentinel))
864
865 testCase.Run(t)
866}
867
868func TestRunDomainname(t *testing.T) {
869 testCase := nerdtest.Setup()

Callers

nothing calls this directly

Calls 12

SetupFunction · 0.92
IdentifierMethod · 0.65
AnyhowMethod · 0.65
SaveMethod · 0.65
TempMethod · 0.65
PathMethod · 0.65
EnsureMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
GetMethod · 0.65
CommandMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…