MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / TestDecodingCorruptedMetadata

Function TestDecodingCorruptedMetadata

cache/redis_cache_test.go:122–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120
121}
122func TestDecodingCorruptedMetadata(t *testing.T) {
123 c := getRedisCache(t)
124
125 // this test will make fetching the length of a payload fail
126 _, _, err := c.decodeMetadata([]byte{})
127 if (err == nil || !errors.Is(err, &RedisCacheCorruptionError{})) {
128 t.Fatalf("expected a corruption error, err=%s", err)
129 }
130
131 // this test will make fetching a string in the metadata fail because it can't read the length of a metadata string
132 _, _, err = c.decodeMetadata([]byte{0, 0, 0, 0, 1, 1, 1, 1})
133 if (err == nil || !errors.Is(err, &RedisCacheCorruptionError{})) {
134 t.Fatalf("expected a corruption error, err=%s", err)
135 }
136 // this test will make fetching a string in the metadata fail because the length of a metadata string doesn't match it's size
137 _, _, err = c.decodeMetadata([]byte{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
138 if (err == nil || !errors.Is(err, &RedisCacheCorruptionError{})) {
139 t.Fatalf("expected a corruption error, err=%s", err)
140 }
141
142}
143
144func TestKeyExpirationWhileFetchtingRedis(t *testing.T) {
145 cache, redis := getRedisCacheAndServer(t)

Callers

nothing calls this directly

Calls 2

getRedisCacheFunction · 0.85
decodeMetadataMethod · 0.80

Tested by

no test coverage detected