Skip to content

Commit

Permalink
test: add relationtuple definition tests (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored Jan 27, 2021
1 parent 41980ba commit 2e3dcb2
Show file tree
Hide file tree
Showing 2 changed files with 410 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/relationtuple/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,15 @@ func (r *InternalRelationTuple) FromURLQuery(query url.Values) (*InternalRelatio
}

func (r *InternalRelationTuple) ToURLQuery() url.Values {
return url.Values{
vals := url.Values{
"namespace": []string{r.Namespace},
"object": []string{r.Object},
"relation": []string{r.Relation},
"subject": []string{r.Subject.String()},
}
if r.Subject != nil {
vals.Set("subject", r.Subject.String())
}
return vals
}

func (q *RelationQuery) FromProto(query *acl.ListRelationTuplesRequest_Query) *RelationQuery {
Expand Down Expand Up @@ -350,13 +353,13 @@ func (r *InternalRelationTuple) Interface() interface{} {
return r
}

func NewProtoRelationCollection(rels []*acl.RelationTuple) cmdx.Table {
func NewProtoRelationCollection(rels []*acl.RelationTuple) *relationCollection {
return &relationCollection{
protoRelations: rels,
}
}

func NewRelationCollection(rels []*InternalRelationTuple) cmdx.Table {
func NewRelationCollection(rels []*InternalRelationTuple) *relationCollection {
return &relationCollection{
internalRelations: rels,
}
Expand Down
Loading

0 comments on commit 2e3dcb2

Please sign in to comment.