MCPcopy Index your code
hub / github.com/cli/cli / TestCache_ExportData

Function TestCache_ExportData

pkg/cmd/cache/shared/shared_test.go:76–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestCache_ExportData(t *testing.T) {
77 src := heredoc.Doc(
78 `
79 {
80 "id": 505,
81 "ref": "refs/heads/main",
82 "key": "Linux-node-958aff96db2d75d67787d1e634ae70b659de937b",
83 "version": "73885106f58cc52a7df9ec4d4a5622a5614813162cb516c759a30af6bf56e6f0",
84 "last_accessed_at": "2019-01-24T22:45:36.000Z",
85 "created_at": "2019-01-24T22:45:36.000Z",
86 "size_in_bytes": 1024
87 }
88 `,
89 )
90
91 tests := []struct {
92 name string
93 fields []string
94 inputJSON string
95 outputJSON string
96 }{
97 {
98 name: "basic",
99 fields: []string{"id", "key"},
100 inputJSON: src,
101 outputJSON: heredoc.Doc(
102 `
103 {
104 "id": 505,
105 "key": "Linux-node-958aff96db2d75d67787d1e634ae70b659de937b"
106 }
107 `,
108 ),
109 },
110 {
111 name: "full",
112 fields: []string{"id", "ref", "key", "version", "lastAccessedAt", "createdAt", "sizeInBytes"},
113 inputJSON: src,
114 outputJSON: heredoc.Doc(
115 `
116 {
117 "createdAt": "2019-01-24T22:45:36Z",
118 "id": 505,
119 "key": "Linux-node-958aff96db2d75d67787d1e634ae70b659de937b",
120 "lastAccessedAt": "2019-01-24T22:45:36Z",
121 "ref": "refs/heads/main",
122 "sizeInBytes": 1024,
123 "version": "73885106f58cc52a7df9ec4d4a5622a5614813162cb516c759a30af6bf56e6f0"
124 }
125 `,
126 ),
127 },
128 }
129
130 for _, tt := range tests {
131 t.Run(tt.name, func(t *testing.T) {
132 var cache Cache
133 dec := json.NewDecoder(strings.NewReader(tt.inputJSON))

Callers

nothing calls this directly

Calls 4

ExportDataMethod · 0.95
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected