fix(platform): platform test and pointers

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
pull/10616/head
Leonardo Di Donato 2018-10-09 15:13:50 +02:00 committed by Chris Goller
parent 639a245fa9
commit ad7b756e45
2 changed files with 14 additions and 13 deletions

View File

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

View File

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