diff --git a/http/bucket_test.go b/http/bucket_test.go index 136b16c859..2aa5993f78 100644 --- a/http/bucket_test.go +++ b/http/bucket_test.go @@ -21,6 +21,7 @@ import ( func TestService_handleGetBuckets(t *testing.T) { type fields struct { BucketService platform.BucketService + LabelService platform.LabelService } type args struct { queryParams map[string][]string @@ -58,6 +59,20 @@ func TestService_handleGetBuckets(t *testing.T) { }, 2, nil }, }, + &mock.LabelService{ + FindLabelsFn: func(ctx context.Context, f platform.LabelFilter) ([]*platform.Label, error) { + labels := []*platform.Label{ + { + ResourceID: f.ResourceID, + Name: "label", + Properties: map[string]string{ + "color": "fff000", + }, + }, + } + return labels, nil + }, + }, }, args: args{ map[string][]string{ @@ -85,7 +100,15 @@ func TestService_handleGetBuckets(t *testing.T) { "organizationID": "50f7ba1150f7ba11", "name": "hello", "retentionRules": [{"type": "expire", "everySeconds": 2}], - "labels": [] + "labels": [ + { + "resourceID": "0b501e7e557ab1ed", + "name": "label", + "properties": { + "color": "fff000" + } + } + ] }, { "links": { @@ -98,7 +121,15 @@ func TestService_handleGetBuckets(t *testing.T) { "organizationID": "7e55e118dbabb1ed", "name": "example", "retentionRules": [{"type": "expire", "everySeconds": 86400}], - "labels": [] + "labels": [ + { + "resourceID": "c0175f0077a77005", + "name": "label", + "properties": { + "color": "fff000" + } + } + ] } ] } @@ -113,6 +144,7 @@ func TestService_handleGetBuckets(t *testing.T) { return []*platform.Bucket{}, 0, nil }, }, + &mock.LabelService{}, }, args: args{ map[string][]string{ @@ -136,7 +168,7 @@ func TestService_handleGetBuckets(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { mappingService := mock.NewUserResourceMappingService() - labelService := mock.NewLabelService() + labelService := tt.fields.LabelService userService := mock.NewUserService() h := NewBucketHandler(mappingService, labelService, userService) h.BucketService = tt.fields.BucketService @@ -165,8 +197,8 @@ func TestService_handleGetBuckets(t *testing.T) { if tt.wants.contentType != "" && content != tt.wants.contentType { t.Errorf("%q. handleGetBuckets() = %v, want %v", tt.name, content, tt.wants.contentType) } - if eq, diff, _ := jsonEqual(string(body), tt.wants.body); tt.wants.body != "" && !eq { - t.Errorf("%q. handleGetBuckets() = ***%s***", tt.name, diff) + if eq, diff, err := jsonEqual(string(body), tt.wants.body); err != nil || tt.wants.body != "" && !eq { + t.Errorf("%q. handleGetBuckets() = ***%v***", tt.name, diff) } }) }