MCPcopy
hub / github.com/nats-io/nats.go / TestKeyValueCompression

Function TestKeyValueCompression

test/kv_test.go:1737–1769  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1735}
1736
1737func TestKeyValueCompression(t *testing.T) {
1738 s := RunBasicJetStreamServer()
1739 defer shutdownJSServerAndRemoveStorage(t, s)
1740
1741 nc, js := jsClient(t, s)
1742 defer nc.Close()
1743
1744 kv, err := js.CreateKeyValue(&nats.KeyValueConfig{
1745 Bucket: "A",
1746 Compression: true,
1747 })
1748 if err != nil {
1749 t.Fatalf("Error creating kv: %v", err)
1750 }
1751
1752 status, err := kv.Status()
1753 if err != nil {
1754 t.Fatalf("Error getting bucket status: %v", err)
1755 }
1756
1757 if !status.IsCompressed() {
1758 t.Fatalf("Expected bucket to be compressed")
1759 }
1760
1761 kvStream, err := js.StreamInfo("KV_A")
1762 if err != nil {
1763 t.Fatalf("Error getting stream info: %v", err)
1764 }
1765
1766 if kvStream.Config.Compression != nats.S2Compression {
1767 t.Fatalf("Expected stream to be compressed with S2")
1768 }
1769}
1770
1771func TestListKeysFromPurgedStream(t *testing.T) {
1772 s := RunBasicJetStreamServer()

Callers

nothing calls this directly

Calls 9

FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
jsClientFunction · 0.70
CreateKeyValueMethod · 0.65
StatusMethod · 0.65
IsCompressedMethod · 0.65
StreamInfoMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected