(t *testing.T)
| 834 | } |
| 835 | |
| 836 | func 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 | |
| 868 | func TestRunDomainname(t *testing.T) { |
| 869 | testCase := nerdtest.Setup() |
nothing calls this directly
no test coverage detected
searching dependent graphs…