feedx 0.12.6 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -49
  3. data/.golangci.yml +13 -0
  4. data/.rubocop.yml +8 -14
  5. data/.tool-versions +1 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +54 -69
  8. data/Makefile +3 -3
  9. data/README.md +3 -1
  10. data/compression.go +29 -0
  11. data/compression_test.go +73 -61
  12. data/consumer.go +96 -152
  13. data/consumer_test.go +124 -59
  14. data/example_test.go +140 -0
  15. data/feedx.gemspec +3 -10
  16. data/feedx.go +16 -31
  17. data/feedx_ext_test.go +13 -3
  18. data/feedx_test.go +24 -24
  19. data/format.go +29 -19
  20. data/format_test.go +84 -56
  21. data/go.mod +12 -10
  22. data/go.sum +18 -142
  23. data/incremental.go +122 -0
  24. data/incremental_test.go +62 -0
  25. data/lib/feedx/cache/abstract.rb +3 -3
  26. data/lib/feedx/cache/value.rb +6 -6
  27. data/lib/feedx/compression/abstract.rb +2 -2
  28. data/lib/feedx/compression/gzip.rb +4 -4
  29. data/lib/feedx/consumer.rb +8 -8
  30. data/lib/feedx/format/abstract.rb +6 -6
  31. data/lib/feedx/format/json.rb +2 -2
  32. data/lib/feedx/format/protobuf.rb +6 -6
  33. data/lib/feedx/format.rb +1 -3
  34. data/lib/feedx/producer.rb +11 -11
  35. data/lib/feedx/stream.rb +2 -2
  36. data/lib/feedx.rb +2 -3
  37. data/manifest.go +65 -0
  38. data/producer.go +34 -137
  39. data/producer_test.go +46 -60
  40. data/reader.go +142 -41
  41. data/reader_test.go +86 -35
  42. data/scheduler.go +176 -0
  43. data/scheduler_test.go +128 -0
  44. data/writer.go +13 -13
  45. data/writer_test.go +61 -44
  46. metadata +15 -137
  47. data/ext/parquet/decoder.go +0 -170
  48. data/ext/parquet/decoder_test.go +0 -88
  49. data/ext/parquet/go.mod +0 -10
  50. data/ext/parquet/go.sum +0 -154
  51. data/ext/parquet/parquet.go +0 -78
  52. data/ext/parquet/parquet_test.go +0 -28
  53. data/ext/parquet/reader.go +0 -89
  54. data/ext/parquet/testdata/alltypes_plain.parquet +0 -0
  55. data/ext/parquet/types.go +0 -51
  56. data/lib/feedx/format/parquet.rb +0 -102
  57. data/spec/feedx/cache/memory_spec.rb +0 -23
  58. data/spec/feedx/cache/value_spec.rb +0 -19
  59. data/spec/feedx/compression/gzip_spec.rb +0 -17
  60. data/spec/feedx/compression/none_spec.rb +0 -15
  61. data/spec/feedx/compression_spec.rb +0 -19
  62. data/spec/feedx/consumer_spec.rb +0 -49
  63. data/spec/feedx/format/abstract_spec.rb +0 -21
  64. data/spec/feedx/format/json_spec.rb +0 -27
  65. data/spec/feedx/format/parquet_spec.rb +0 -30
  66. data/spec/feedx/format/protobuf_spec.rb +0 -23
  67. data/spec/feedx/format_spec.rb +0 -21
  68. data/spec/feedx/producer_spec.rb +0 -74
  69. data/spec/feedx/stream_spec.rb +0 -109
  70. data/spec/spec_helper.rb +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab1b8d12efde331dcd1ca96c686c29e1ef16ab895f049121078b9f0503d23276
4
- data.tar.gz: 3d51319d3ea39cbceeb480252e06c37238fce0cda68aa6b65cf1f59c0f0af38b
3
+ metadata.gz: c1978c7def650e2a2630e36fc0bfc59b9eb66c5ead0f7dda9cc83e773a85c1d8
4
+ data.tar.gz: 548208072baf9e6f84a7541df5e8a22a5960982007bce4385c7fa538e0290e94
5
5
  SHA512:
6
- metadata.gz: d08c34b59158c69d500b7cffe8019550dafa87b760e4b0cb3b25afc367801a3f3473486987dcb62e5c1bc62c05d3653bf26692fcbdcbb552d2af1073f4eced50
7
- data.tar.gz: cfa3f24458cead0c12c1f03b559ded816095e1e9cf29a1918c142cd255f782fa3c51d7c45ca5833ab25b5a745e0e68f4b1b1062c7760c56ff1b57da122767135
6
+ metadata.gz: a5b0be41feeafabbffcbbda6ccc1b12df4d24b8d9a9f03f4b8d04ce2fec7b644b99f15db98e67a79294dca1c3b56c072a67ab20b8cbffaed25ec502e74de9ca2
7
+ data.tar.gz: d3434d54accaf281ec5e06e25753de74a052d1386a63badf97ff8bfa8a1426162528d8256cbd288969ef1c348d24cf9358c0827b4c7b1af500c71e5349900b63
@@ -8,53 +8,6 @@ on:
8
8
  - main
9
9
  jobs:
10
10
  go:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- go-version: [1.15.x, 1.16.x]
15
- steps:
16
- - name: Fetch staticcheck
17
- uses: engineerd/configurator@v0.0.6
18
- with:
19
- name: staticcheck
20
- fromGitHubReleases: true
21
- repo: dominikh/go-tools
22
- version: latest
23
- urlTemplate: "https://github.com/dominikh/go-tools/releases/download/2020.2.3/staticcheck_linux_amd64.tar.gz"
24
- pathInArchive: staticcheck/staticcheck
25
- token: ${{ secrets.GITHUB_TOKEN }}
26
- - name: Checkout
27
- uses: actions/checkout@v2
28
- - name: Cache dependencies
29
- uses: actions/cache@v2
30
- with:
31
- path: ~/go/pkg/mod
32
- key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33
- restore-keys: |
34
- ${{ runner.os }}-go-
35
- - name: Setup Go
36
- uses: actions/setup-go@v2
37
- with:
38
- go-version: ${{ matrix.go-version }}
39
- - name: Run tests
40
- run: make test
41
- - name: Run staticcheck
42
- run: make staticcheck
11
+ uses: bsm/misc/.github/workflows/test-go.yml@main
43
12
  ruby:
44
- runs-on: ubuntu-latest
45
- strategy:
46
- matrix:
47
- ruby-version: ["2.6", "2.7", "3.0"]
48
- steps:
49
- - name: Install libarrow
50
- run: |
51
- wget https://apache.bintray.com/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb
52
- sudo apt install -y ./apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb
53
- sudo apt update
54
- sudo apt install -y libarrow-dev libarrow-glib-dev libarrow-dataset-dev libplasma-dev libplasma-glib-dev libgandiva-dev libgandiva-glib-dev libparquet-dev libparquet-glib-dev
55
- - uses: actions/checkout@v2
56
- - uses: ruby/setup-ruby@v1
57
- with:
58
- ruby-version: ${{ matrix.ruby-version }}
59
- bundler-cache: true
60
- - run: bundle exec rake
13
+ uses: bsm/misc/.github/workflows/test-ruby.yml@main
data/.golangci.yml ADDED
@@ -0,0 +1,13 @@
1
+ version: "2"
2
+ linters:
3
+ settings:
4
+ errcheck:
5
+ exclude-functions:
6
+ - (*github.com/bsm/feedx.Writer).Discard
7
+ - (*github.com/bsm/feedx.Reader).Close
8
+ - (github.com/bsm/feedx.Consumer).Close
9
+ - (*github.com/bsm/feedx.IncrementalProducer).Close
10
+ - (*github.com/bsm/feedx.Producer).Close
11
+ - (*github.com/bsm/bfs.InMem).Close
12
+ - (*github.com/bsm/bfs.Object).Close
13
+ - (github.com/bsm/bfs.Writer).Discard
data/.rubocop.yml CHANGED
@@ -1,17 +1,11 @@
1
- inherit_gem:
2
- rubocop-bsm:
3
- - default.yml
1
+ plugins:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ inherit_from:
6
+ - https://raw.githubusercontent.com/bsm/misc/refs/heads/main/rubocop/default.yml
7
+ - https://raw.githubusercontent.com/bsm/misc/refs/heads/main/rubocop/rspec.yml
8
+
4
9
  inherit_mode:
5
10
  merge:
6
11
  - Exclude
7
-
8
- AllCops:
9
- TargetRubyVersion: 2.6
10
- Naming/MethodParameterName:
11
- MinNameLength: 2
12
- Naming/MemoizedInstanceVariableName:
13
- Enabled: false
14
- Naming/FileName:
15
- Exclude: [lib/sortable-by.rb]
16
- Metrics/ParameterLists:
17
- Max: 8
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.4.7
data/Gemfile CHANGED
@@ -1,2 +1,10 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+ gem 'bundler'
5
+ gem 'pbio'
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'rubocop'
9
+ gem 'rubocop-rake'
10
+ gem 'rubocop-rspec'
data/Gemfile.lock CHANGED
@@ -1,83 +1,67 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedx (0.12.6)
4
+ feedx (0.14.0)
5
5
  bfs (>= 0.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.2)
11
- bfs (0.8.4)
12
- bigdecimal (3.0.2)
13
- diff-lcs (1.4.4)
14
- extpp (0.0.9)
15
- gio2 (3.4.4)
16
- gobject-introspection (= 3.4.4)
17
- glib2 (3.4.4)
18
- native-package-installer (>= 1.0.3)
19
- pkg-config (>= 1.3.5)
20
- gobject-introspection (3.4.4)
21
- glib2 (= 3.4.4)
22
- google-protobuf (3.17.3)
23
- native-package-installer (1.1.1)
24
- parallel (1.20.1)
25
- parser (3.0.1.1)
10
+ ast (2.4.3)
11
+ bfs (0.9.1)
12
+ diff-lcs (1.6.2)
13
+ google-protobuf (3.25.8)
14
+ json (2.16.0)
15
+ language_server-protocol (3.17.0.5)
16
+ lint_roller (1.1.0)
17
+ parallel (1.27.0)
18
+ parser (3.3.10.0)
26
19
  ast (~> 2.4.1)
27
- pbio (0.3.0)
28
- google-protobuf
29
- pkg-config (1.4.6)
30
- rainbow (3.0.0)
31
- rake (13.0.3)
32
- red-arrow (3.0.0)
33
- bigdecimal (>= 2.0.3)
34
- extpp (>= 0.0.7)
35
- gio2 (>= 3.3.6)
36
- native-package-installer
37
- pkg-config
38
- red-parquet (3.0.0)
39
- red-arrow (= 3.0.0)
40
- regexp_parser (2.1.1)
41
- rexml (3.2.5)
42
- rspec (3.10.0)
43
- rspec-core (~> 3.10.0)
44
- rspec-expectations (~> 3.10.0)
45
- rspec-mocks (~> 3.10.0)
46
- rspec-core (3.10.1)
47
- rspec-support (~> 3.10.0)
48
- rspec-expectations (3.10.1)
20
+ racc
21
+ pbio (0.4.0)
22
+ google-protobuf (> 3, < 4)
23
+ prism (1.6.0)
24
+ racc (1.8.1)
25
+ rainbow (3.1.1)
26
+ rake (13.3.1)
27
+ regexp_parser (2.11.3)
28
+ rspec (3.13.2)
29
+ rspec-core (~> 3.13.0)
30
+ rspec-expectations (~> 3.13.0)
31
+ rspec-mocks (~> 3.13.0)
32
+ rspec-core (3.13.6)
33
+ rspec-support (~> 3.13.0)
34
+ rspec-expectations (3.13.5)
49
35
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.10.0)
51
- rspec-mocks (3.10.2)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-mocks (3.13.7)
52
38
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.10.0)
54
- rspec-support (3.10.2)
55
- rubocop (1.17.0)
39
+ rspec-support (~> 3.13.0)
40
+ rspec-support (3.13.6)
41
+ rubocop (1.81.7)
42
+ json (~> 2.3)
43
+ language_server-protocol (~> 3.17.0.2)
44
+ lint_roller (~> 1.1.0)
56
45
  parallel (~> 1.10)
57
- parser (>= 3.0.0.0)
46
+ parser (>= 3.3.0.2)
58
47
  rainbow (>= 2.2.2, < 4.0)
59
- regexp_parser (>= 1.8, < 3.0)
60
- rexml
61
- rubocop-ast (>= 1.7.0, < 2.0)
48
+ regexp_parser (>= 2.9.3, < 3.0)
49
+ rubocop-ast (>= 1.47.1, < 2.0)
62
50
  ruby-progressbar (~> 1.7)
63
- unicode-display_width (>= 1.4.0, < 3.0)
64
- rubocop-ast (1.7.0)
65
- parser (>= 3.0.1.1)
66
- rubocop-bsm (0.6.0)
67
- rubocop (~> 1.0)
68
- rubocop-performance
69
- rubocop-rake
70
- rubocop-rspec
71
- rubocop-performance (1.11.3)
72
- rubocop (>= 1.7.0, < 2.0)
73
- rubocop-ast (>= 0.4.0)
74
- rubocop-rake (0.5.1)
75
- rubocop
76
- rubocop-rspec (2.4.0)
77
- rubocop (~> 1.0)
78
- rubocop-ast (>= 1.1.0)
79
- ruby-progressbar (1.11.0)
80
- unicode-display_width (2.0.0)
51
+ unicode-display_width (>= 2.4.0, < 4.0)
52
+ rubocop-ast (1.48.0)
53
+ parser (>= 3.3.7.2)
54
+ prism (~> 1.4)
55
+ rubocop-rake (0.7.1)
56
+ lint_roller (~> 1.1)
57
+ rubocop (>= 1.72.1)
58
+ rubocop-rspec (3.7.0)
59
+ lint_roller (~> 1.1)
60
+ rubocop (~> 1.72, >= 1.72.1)
61
+ ruby-progressbar (1.13.0)
62
+ unicode-display_width (3.2.0)
63
+ unicode-emoji (~> 4.1)
64
+ unicode-emoji (4.1.0)
81
65
 
82
66
  PLATFORMS
83
67
  ruby
@@ -87,9 +71,10 @@ DEPENDENCIES
87
71
  feedx!
88
72
  pbio
89
73
  rake
90
- red-parquet (>= 3.0, < 4.0)
91
74
  rspec
92
- rubocop-bsm
75
+ rubocop
76
+ rubocop-rake
77
+ rubocop-rspec
93
78
 
94
79
  BUNDLED WITH
95
- 2.1.4
80
+ 2.3.16
data/Makefile CHANGED
@@ -1,9 +1,9 @@
1
1
  default: test
2
2
 
3
- .common.makefile:
4
- curl -fsSL -o $@ https://gitlab.com/bsm/misc/raw/master/make/go/common.makefile
3
+ .minimal.makefile:
4
+ curl -fsSL -o $@ https://gitlab.com/bsm/misc/raw/master/make/go/minimal.makefile
5
5
 
6
- include .common.makefile
6
+ include .minimal.makefile
7
7
 
8
8
  proto: internal/testdata/testdata.pb.go
9
9
 
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Feedx
2
2
 
3
- [![Test](https://github.com/bsm/feedx/actions/workflows/test.yml/badge.svg)](https://github.com/bsm/feedx/actions/workflows/test.yml)
3
+ [![Go reference](https://pkg.go.dev/badge/github.com/bsm/feedx.svg)](https://pkg.go.dev/github.com/bsm/feedx)
4
+ [![GitHub release](https://img.shields.io/github/tag/bsm/feedx.svg?label=release)](https://github.com/bsm/feedx/releases)
5
+ [![Go Report Card](https://goreportcard.com/badge/github.com/bsm/feedx)](https://goreportcard.com/report/github.com/bsm/feedx)
4
6
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
7
 
6
8
  Feed-based data exchange between services.
data/compression.go CHANGED
@@ -5,6 +5,8 @@ import (
5
5
  "compress/gzip"
6
6
  "io"
7
7
  "path"
8
+
9
+ "github.com/klauspost/compress/zstd"
8
10
  )
9
11
 
10
12
  // Compression represents the data compression.
@@ -23,6 +25,8 @@ func DetectCompression(name string) Compression {
23
25
  return GZipCompression
24
26
  } else if ext == ".flate" {
25
27
  return FlateCompression
28
+ } else if ext == ".zst" {
29
+ return ZstdCompression
26
30
  }
27
31
  }
28
32
  return NoCompression
@@ -79,3 +83,28 @@ func (flateCompression) NewReader(r io.Reader) (io.ReadCloser, error) {
79
83
  func (flateCompression) NewWriter(w io.Writer) (io.WriteCloser, error) {
80
84
  return flate.NewWriter(w, flate.BestSpeed)
81
85
  }
86
+
87
+ // --------------------------------------------------------------------
88
+
89
+ // ZstdCompression supports zstd compression format.
90
+ var ZstdCompression = zstdCompression{}
91
+
92
+ type zstdCompression struct{}
93
+
94
+ func (zstdCompression) NewReader(r io.Reader) (io.ReadCloser, error) {
95
+ zr, err := zstd.NewReader(r)
96
+ if err != nil {
97
+ return nil, err
98
+ }
99
+ return zstdDecoder{Decoder: zr}, nil
100
+ }
101
+
102
+ func (zstdCompression) NewWriter(w io.Writer) (io.WriteCloser, error) {
103
+ return zstd.NewWriter(w)
104
+ }
105
+
106
+ type zstdDecoder struct {
107
+ *zstd.Decoder
108
+ }
109
+
110
+ func (zstdDecoder) Close() error { return nil }
data/compression_test.go CHANGED
@@ -2,77 +2,89 @@ package feedx_test
2
2
 
3
3
  import (
4
4
  "bytes"
5
+ "testing"
5
6
 
6
7
  "github.com/bsm/feedx"
7
- . "github.com/bsm/ginkgo"
8
- . "github.com/bsm/gomega"
9
8
  )
10
9
 
11
- var _ = Describe("Compression", func() {
12
- var data = bytes.Repeat([]byte("wxyz"), 1024)
13
-
14
- runSharedTest := func(subject feedx.Compression) {
15
- buf := new(bytes.Buffer)
16
-
17
- w, err := subject.NewWriter(buf)
18
- Expect(err).NotTo(HaveOccurred())
19
- defer w.Close()
20
-
21
- Expect(w.Write(data)).To(Equal(4096))
22
- Expect(w.Write(data)).To(Equal(4096))
23
- Expect(w.Close()).To(Succeed())
24
-
25
- r, err := subject.NewReader(buf)
26
- Expect(err).NotTo(HaveOccurred())
27
- defer r.Close()
28
-
29
- p := make([]byte, 20)
30
- Expect(r.Read(p)).To(Equal(20))
31
- Expect(string(p)).To(Equal("wxyzwxyzwxyzwxyzwxyz"))
32
- Expect(r.Close()).To(Succeed())
10
+ func TestDetectCompression(t *testing.T) {
11
+ examples := []struct {
12
+ Input string
13
+ Exp feedx.Compression
14
+ }{
15
+ {Input: "/path/to/file.json", Exp: feedx.NoCompression},
16
+ {Input: "/path/to/file.json.gz", Exp: feedx.GZipCompression},
17
+ {Input: "/path/to/file.jsonz", Exp: feedx.GZipCompression},
18
+ {Input: "/path/to/file.pb", Exp: feedx.NoCompression},
19
+ {Input: "/path/to/file.pb.gz", Exp: feedx.GZipCompression},
20
+ {Input: "/path/to/file.pbz", Exp: feedx.GZipCompression},
21
+ {Input: "/path/to/file.flate", Exp: feedx.FlateCompression},
22
+ {Input: "/path/to/file.whatever.flate", Exp: feedx.FlateCompression},
23
+ {Input: "/path/to/file.zst", Exp: feedx.ZstdCompression},
24
+ {Input: "", Exp: feedx.NoCompression},
25
+ {Input: "/path/to/file", Exp: feedx.NoCompression},
26
+ {Input: "/path/to/file.txt", Exp: feedx.NoCompression},
33
27
  }
28
+ for _, x := range examples {
29
+ if got := feedx.DetectCompression(x.Input); got != x.Exp {
30
+ t.Errorf("expected %s for %q, but got %s", x.Exp, x.Input, got)
31
+ }
32
+ }
33
+ }
34
34
 
35
- It("detects the format", func() {
36
- Expect(feedx.DetectCompression("/path/to/file.json")).To(Equal(feedx.NoCompression))
37
- Expect(feedx.DetectCompression("/path/to/file.json.gz")).To(Equal(feedx.GZipCompression))
38
- Expect(feedx.DetectCompression("/path/to/file.jsonz")).To(Equal(feedx.GZipCompression))
39
-
40
- Expect(feedx.DetectCompression("/path/to/file.pb")).To(Equal(feedx.NoCompression))
41
- Expect(feedx.DetectCompression("/path/to/file.pb.gz")).To(Equal(feedx.GZipCompression))
42
- Expect(feedx.DetectCompression("/path/to/file.pbz")).To(Equal(feedx.GZipCompression))
43
-
44
- Expect(feedx.DetectCompression("/path/to/file.flate")).To(Equal(feedx.FlateCompression))
45
- Expect(feedx.DetectCompression("/path/to/file.whatever.flate")).To(Equal(feedx.FlateCompression))
35
+ func TestCompression(t *testing.T) {
36
+ data := bytes.Repeat([]byte("wxyz"), 1024)
46
37
 
47
- Expect(feedx.DetectCompression("")).To(Equal(feedx.NoCompression))
48
- Expect(feedx.DetectCompression("/path/to/file")).To(Equal(feedx.NoCompression))
49
- Expect(feedx.DetectCompression("/path/to/file.txt")).To(Equal(feedx.NoCompression))
38
+ t.Run("no compression", func(t *testing.T) {
39
+ testCompression(t, feedx.NoCompression, data)
50
40
  })
51
-
52
- Describe("NoCompression", func() {
53
- var subject = feedx.NoCompression
54
- var _ feedx.Compression = subject
55
-
56
- It("writes/reads", func() {
57
- runSharedTest(subject)
58
- })
41
+ t.Run("gzip", func(t *testing.T) {
42
+ testCompression(t, feedx.GZipCompression, data)
43
+ })
44
+ t.Run("flate", func(t *testing.T) {
45
+ testCompression(t, feedx.FlateCompression, data)
59
46
  })
47
+ t.Run("zstd", func(t *testing.T) {
48
+ testCompression(t, feedx.ZstdCompression, data)
49
+ })
50
+ }
60
51
 
61
- Describe("GZipCompression", func() {
62
- var subject = feedx.GZipCompression
63
- var _ feedx.Compression = subject
52
+ func testCompression(t *testing.T, c feedx.Compression, data []byte) {
53
+ t.Helper()
54
+ buf := new(bytes.Buffer)
64
55
 
65
- It("writes/reads", func() {
66
- runSharedTest(subject)
67
- })
68
- })
56
+ w, err := c.NewWriter(buf)
57
+ if err != nil {
58
+ t.Fatal("expected no error, got", err)
59
+ }
60
+ defer func() { _ = w.Close() }()
69
61
 
70
- Describe("FlateCompression", func() {
71
- var subject = feedx.FlateCompression
72
- var _ feedx.Compression = subject
62
+ if _, err := w.Write(data); err != nil {
63
+ t.Fatal("expected no error, got", err)
64
+ }
65
+ if _, err := w.Write(data); err != nil {
66
+ t.Fatal("expected no error, got", err)
67
+ }
68
+ if err := w.Close(); err != nil {
69
+ t.Fatal("expected no error, got", err)
70
+ }
73
71
 
74
- It("writes/reads", func() {
75
- runSharedTest(subject)
76
- })
77
- })
78
- })
72
+ r, err := c.NewReader(buf)
73
+ if err != nil {
74
+ t.Fatal("expected no error, got", err)
75
+ }
76
+ defer func() { _ = r.Close() }()
77
+
78
+ p := make([]byte, 20)
79
+ if n, err := r.Read(p); err != nil {
80
+ t.Fatal("expected no error, got", err)
81
+ } else if n != 20 {
82
+ t.Errorf("expected to read 20 bytes, got %d", n)
83
+ } else if exp, got := "wxyzwxyzwxyzwxyzwxyz", string(p); exp != got {
84
+ t.Errorf("expected %q, got %q", exp, got)
85
+ }
86
+
87
+ if err := r.Close(); err != nil {
88
+ t.Fatal("expected no error, got", err)
89
+ }
90
+ }