Skip to content

Commit

Permalink
Update snappy import in SnappyCompressor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiecuthill committed Jul 17, 2015
1 parent 01eb6c9 commit b907cb3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ Maciek Sakrejda <maciek@heroku.com>
Jeff Mitchell <jeffrey.mitchell@gmail.com>
Baptiste Fontaine <b@ptistefontaine.fr>
Matt Heath <matt@mattheath.com>
Jamie Cuthill <jamie.cuthill@gmail.com>
4 changes: 2 additions & 2 deletions compressor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gocql

import (
"github.com/golang/snappy/snappy"
"github.com/golang/snappy"
)

type Compressor interface {
Expand All @@ -20,7 +20,7 @@ func (s SnappyCompressor) Name() string {
}

func (s SnappyCompressor) Encode(data []byte) ([]byte, error) {
return snappy.Encode(nil, data)
return snappy.Encode(nil, data), nil
}

func (s SnappyCompressor) Decode(data []byte) ([]byte, error) {
Expand Down
8 changes: 4 additions & 4 deletions compressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ package gocql

import (
"bytes"
"github.com/golang/snappy/snappy"
"testing"

"github.com/golang/snappy"
)

func TestSnappyCompressor(t *testing.T) {
Expand All @@ -16,9 +17,8 @@ func TestSnappyCompressor(t *testing.T) {

str := "My Test String"
//Test Encoding
if expected, err := snappy.Encode(nil, []byte(str)); err != nil {
t.Fatalf("failed to encode '%v' with error %v", str, err)
} else if res, err := c.Encode([]byte(str)); err != nil {
expected := snappy.Encode(nil, []byte(str))
if res, err := c.Encode([]byte(str)); err != nil {
t.Fatalf("failed to encode '%v' with error %v", str, err)
} else if bytes.Compare(expected, res) != 0 {
t.Fatal("failed to match the expected encoded value with the result encoded value.")
Expand Down

0 comments on commit b907cb3

Please sign in to comment.