From ad7b756e45fa75df84d7c24936fc9e9d2acf26c8 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Tue, 9 Oct 2018 15:13:50 +0200 Subject: [PATCH] fix(platform): platform test and pointers Signed-off-by: Leonardo Di Donato --- http/dashboard_service.go | 7 ++++--- user_resource_mapping_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/http/dashboard_service.go b/http/dashboard_service.go index 899d075390..afdd87a3cc 100644 --- a/http/dashboard_service.go +++ b/http/dashboard_service.go @@ -194,16 +194,17 @@ func decodeGetDashboardsRequest(ctx context.Context, r *http.Request) (*getDashb qp := r.URL.Query() req := &getDashboardsRequest{} + initialID := platform.InvalidID() if ids, ok := qp["id"]; ok { for _, id := range ids { - i := platform.InvalidID() + i := initialID if err := i.DecodeFromString(id); err != nil { return nil, err } - req.filter.IDs = append(req.filter.IDs, i) + req.filter.IDs = append(req.filter.IDs, &i) } } else if owner := qp.Get("owner"); owner != "" { - req.ownerID = platform.InvalidID() + req.ownerID = &initialID if err := req.ownerID.DecodeFromString(owner); err != nil { return nil, err } diff --git a/user_resource_mapping_test.go b/user_resource_mapping_test.go index d7ce4dcba7..6a21eaa06b 100644 --- a/user_resource_mapping_test.go +++ b/user_resource_mapping_test.go @@ -9,10 +9,10 @@ import ( func TestOwnerMappingValidate(t *testing.T) { type fields struct { - ResourceID ID - ResourceType ResourceType - UserID ID - UserType UserType + ResourceID platform.ID + ResourceType platform.ResourceType + UserID platform.ID + UserType platform.UserType } tests := []struct { name string @@ -24,7 +24,7 @@ func TestOwnerMappingValidate(t *testing.T) { fields: fields{ UserID: platformtesting.MustIDFromString("debac1e0deadbeef"), UserType: platform.Owner, - ResourceType: DashboardResourceType, + ResourceType: platform.DashboardResourceType, }, wantErr: true, }, @@ -33,7 +33,7 @@ func TestOwnerMappingValidate(t *testing.T) { fields: fields{ ResourceID: platformtesting.MustIDFromString("020f755c3c082000"), UserType: platform.Owner, - ResourceType: DashboardResourceType, + ResourceType: platform.DashboardResourceType, }, wantErr: true, }, @@ -42,7 +42,7 @@ func TestOwnerMappingValidate(t *testing.T) { fields: fields{ ResourceID: platformtesting.MustIDFromString("020f755c3c082000"), UserID: platformtesting.MustIDFromString("debac1e0deadbeef"), - ResourceType: DashboardResourceType, + ResourceType: platform.DashboardResourceType, }, wantErr: true, }, @@ -51,7 +51,7 @@ func TestOwnerMappingValidate(t *testing.T) { fields: fields{ ResourceID: platformtesting.MustIDFromString("020f755c3c082000"), UserID: platformtesting.MustIDFromString("debac1e0deadbeef"), - UserType: Owner, + UserType: platform.Owner, }, wantErr: true, }, @@ -61,7 +61,7 @@ func TestOwnerMappingValidate(t *testing.T) { ResourceID: platformtesting.MustIDFromString("020f755c3c082000"), UserID: platformtesting.MustIDFromString("debac1e0deadbeef"), UserType: "foo", - ResourceType: DashboardResourceType, + ResourceType: platform.DashboardResourceType, }, wantErr: true, }, @@ -70,7 +70,7 @@ func TestOwnerMappingValidate(t *testing.T) { fields: fields{ ResourceID: platformtesting.MustIDFromString("020f755c3c082000"), UserID: platformtesting.MustIDFromString("debac1e0deadbeef"), - UserType: Owner, + UserType: platform.Owner, ResourceType: "foo", }, wantErr: true,