Fix nil pointer derefernce in gcsstore tests

This commit is contained in:
Marius 2017-11-21 14:29:28 +01:00
parent f347495e55
commit 6f9b66f3ad
1 changed files with 30 additions and 50 deletions

View File

@ -45,11 +45,9 @@ func TestGetObjectSize(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
size, err := service.GetObjectSize(GCSObjectParams{ size, err := service.GetObjectSize(GCSObjectParams{
@ -94,11 +92,9 @@ func TestDeleteObjectWithFilter(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
err = service.DeleteObjectsWithFilter(GCSFilterParams{ err = service.DeleteObjectsWithFilter(GCSFilterParams{
@ -182,11 +178,9 @@ func TestComposeObjects(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
err = service.ComposeObjects(GCSComposeParams{ err = service.ComposeObjects(GCSComposeParams{
@ -226,11 +220,9 @@ func TestGetObjectAttrs(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
attrs, err := service.GetObjectAttrs(GCSObjectParams{ attrs, err := service.GetObjectAttrs(GCSObjectParams{
@ -272,11 +264,9 @@ func TestReadObject(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
reader, err := service.ReadObject(GCSObjectParams{ reader, err := service.ReadObject(GCSObjectParams{
@ -312,11 +302,9 @@ func TestSetObjectMetadata(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
err = service.SetObjectMetadata(GCSObjectParams{ err = service.SetObjectMetadata(GCSObjectParams{
@ -353,11 +341,9 @@ func TestDeleteObject(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
err = service.DeleteObject(GCSObjectParams{ err = service.DeleteObject(GCSObjectParams{
@ -388,11 +374,9 @@ func TestWriteObject(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
reader := bytes.NewReader([]byte{1}) reader := bytes.NewReader([]byte{1})
@ -442,11 +426,9 @@ func TestComposeFrom(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
crc, err := service.ComposeFrom([]*storage.ObjectHandle{client.Bucket("test-bucket").Object("my-object")}, GCSObjectParams{ crc, err := service.ComposeFrom([]*storage.ObjectHandle{client.Bucket("test-bucket").Object("my-object")}, GCSObjectParams{
@ -494,11 +476,9 @@ func TestFilterObject(t *testing.T) {
return return
} }
service, err := NewGCSService("") service := GCSService{
service.Client = client Client: client,
if err != nil { Ctx: ctx,
t.Errorf("Error: %v", err)
return
} }
objects, err := service.FilterObjects(GCSFilterParams{ objects, err := service.FilterObjects(GCSFilterParams{