Browse Source

Update snappy import in SnappyCompressor.

Jamie Cuthill 10 years ago
parent
commit
b907cb3a0e
3 changed files with 7 additions and 6 deletions
  1. 1 0
      AUTHORS
  2. 2 2
      compressor.go
  3. 4 4
      compressor_test.go

+ 1 - 0
AUTHORS

@@ -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>

+ 2 - 2
compressor.go

@@ -1,7 +1,7 @@
 package gocql
 
 import (
-	"github.com/golang/snappy/snappy"
+	"github.com/golang/snappy"
 )
 
 type Compressor interface {
@@ -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) {

+ 4 - 4
compressor_test.go

@@ -4,8 +4,9 @@ package gocql
 
 import (
 	"bytes"
-	"github.com/golang/snappy/snappy"
 	"testing"
+
+	"github.com/golang/snappy"
 )
 
 func TestSnappyCompressor(t *testing.T) {
@@ -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.")