MCPcopy Index your code
hub / github.com/regclient/regclient / TestMod

Function TestMod

mod/mod_test.go:31–1091  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestMod(t *testing.T) {
32 t.Parallel()
33 ctx := context.Background()
34 baseTime, err := time.Parse(time.RFC3339, "2020-01-01T00:00:00Z")
35 if err != nil {
36 t.Fatalf("failed to parse test time: %v", err)
37 }
38 oldTime, err := time.Parse(time.RFC3339, "1999-01-01T00:00:00Z")
39 if err != nil {
40 t.Fatalf("failed to parse test time: %v", err)
41 }
42 bDig := digest.FromString("digest for base image")
43 bRef, err := ref.New("base:latest")
44 if err != nil {
45 t.Fatalf("failed to parse base image: %v", err)
46 }
47 tarBytes, err := os.ReadFile("../testdata/layer.tar")
48 if err != nil {
49 t.Fatalf("failed to read testdata/layer.tar: %v", err)
50 }
51 bTrue := true
52 regSrc := olareg.New(oConfig.Config{
53 Storage: oConfig.ConfigStorage{
54 StoreType: oConfig.StoreMem,
55 RootDir: "../testdata",
56 ReadOnly: &bTrue,
57 },
58 })
59 tSrc := httptest.NewServer(regSrc)
60 tSrcURL, _ := url.Parse(tSrc.URL)
61 tSrcHost := tSrcURL.Host
62 regTgt := olareg.New(oConfig.Config{
63 Storage: oConfig.ConfigStorage{
64 StoreType: oConfig.StoreMem,
65 RootDir: "../testdata",
66 },
67 })
68 tTgt := httptest.NewServer(regTgt)
69 tTgtURL, _ := url.Parse(tTgt.URL)
70 tTgtHost := tTgtURL.Host
71 t.Cleanup(func() {
72 tSrc.Close()
73 _ = regSrc.Close()
74 tTgt.Close()
75 _ = regTgt.Close()
76 })
77 tempDir := t.TempDir()
78 err = copyfs.Copy(filepath.Join(tempDir, "testrepo"), "../testdata/testrepo")
79 if err != nil {
80 t.Fatalf("failed to setup tempDir: %v", err)
81 }
82
83 // create regclient
84 rcHosts := []config.Host{
85 {
86 Name: tSrcHost,
87 Hostname: tSrcHost,
88 TLS: config.TLSDisabled,

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
CopyFunction · 0.92
NewFunction · 0.92
WithConfigHostFunction · 0.92
WithRegOptsFunction · 0.92
WithDelayFunction · 0.92
ParseFunction · 0.92
GetPlatformDescFunction · 0.92
WithManifestToOCIFunction · 0.85
WithRefTgtFunction · 0.85
WithManifestToDockerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…