Skip to content

Commit 44ada47

Browse files
committed
Fixed tests
Signed-off-by: Marco Pracucci <[email protected]>
1 parent 869fe64 commit 44ada47

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pkg/chunk/cache/cache_test.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,24 @@ func fillCache(t *testing.T, cache cache.Cache) ([]string, []chunk.Chunk) {
5252
buf, err := c.Encoded()
5353
require.NoError(t, err)
5454

55+
// In order to be able to compare the expected chunk (this one) with the
56+
// actual one (the one that will be fetched from the cache) we need to
57+
// cleanup the chunk to avoid any internal references mismatch (ie. appender
58+
// pointer).
59+
cleanChunk := chunk.Chunk{
60+
UserID: c.UserID,
61+
Fingerprint: c.Fingerprint,
62+
From: c.From,
63+
Through: c.Through,
64+
Checksum: c.Checksum,
65+
ChecksumSet: c.ChecksumSet,
66+
}
67+
err = cleanChunk.Decode(chunk.NewDecodeContext(), buf)
68+
require.NoError(t, err)
69+
5570
keys = append(keys, c.ExternalKey())
5671
bufs = append(bufs, buf)
57-
chunks = append(chunks, c)
72+
chunks = append(chunks, cleanChunk)
5873
}
5974

6075
cache.Store(context.Background(), keys, bufs)
@@ -75,7 +90,7 @@ func testCacheSingle(t *testing.T, cache cache.Cache, keys []string, chunks []ch
7590
require.NoError(t, err)
7691
err = c.Decode(chunk.NewDecodeContext(), bufs[0])
7792
require.NoError(t, err)
78-
require.Equal(t, c, chunks[index])
93+
require.Equal(t, chunks[index], c)
7994
}
8095
}
8196

0 commit comments

Comments
 (0)