MCPcopy
hub / github.com/aquasecurity/trivy / TestMemoryCache_PutArtifact

Function TestMemoryCache_PutArtifact

pkg/cache/memory_test.go:14–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestMemoryCache_PutArtifact(t *testing.T) {
15 tests := []struct {
16 name string
17 artifactID string
18 artifactInfo types.ArtifactInfo
19 }{
20 {
21 name: "happy path",
22 artifactID: "sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf",
23 artifactInfo: types.ArtifactInfo{
24 SchemaVersion: 2,
25 Architecture: "amd64",
26 Created: time.Date(2020, 11, 14, 0, 20, 4, 0, time.UTC),
27 DockerVersion: "19.03.12",
28 OS: "linux",
29 },
30 },
31 }
32
33 for _, tt := range tests {
34 t.Run(tt.name, func(t *testing.T) {
35 c := cache.NewMemoryCache()
36
37 err := c.PutArtifact(t.Context(), tt.artifactID, tt.artifactInfo)
38 require.NoError(t, err)
39
40 got, err := c.GetArtifact(t.Context(), tt.artifactID)
41 require.NoError(t, err)
42 assert.Equal(t, tt.artifactInfo, got)
43 })
44 }
45}
46
47func TestMemoryCache_PutBlob(t *testing.T) {
48 tests := []struct {

Callers

nothing calls this directly

Calls 6

PutArtifactMethod · 0.95
GetArtifactMethod · 0.95
NewMemoryCacheFunction · 0.92
ContextMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…