| 13 | ) |
| 14 | |
| 15 | func TestCompressionConfig_Validate(t *testing.T) { |
| 16 | tests := map[string]struct { |
| 17 | cfg CompressionConfig |
| 18 | expected error |
| 19 | }{ |
| 20 | "should pass with default config": { |
| 21 | cfg: CompressionConfig{}, |
| 22 | }, |
| 23 | "should pass with snappy compression": { |
| 24 | cfg: CompressionConfig{ |
| 25 | Compression: "snappy", |
| 26 | }, |
| 27 | }, |
| 28 | "should fail with unsupported compression": { |
| 29 | cfg: CompressionConfig{ |
| 30 | Compression: "unsupported", |
| 31 | }, |
| 32 | expected: errUnsupportedCompression, |
| 33 | }, |
| 34 | } |
| 35 | |
| 36 | for testName, testData := range tests { |
| 37 | t.Run(testName, func(t *testing.T) { |
| 38 | assert.Equal(t, testData.expected, testData.cfg.Validate()) |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func TestSnappyCache(t *testing.T) { |
| 44 | ctx := context.Background() |