Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed May 28, 2018
1 parent 7c4fa0f commit 01da219
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions idm/workspace/dao_test.go
Expand Up @@ -129,84 +129,6 @@ func TestUniqueSlug(t *testing.T) {
})
}

func TestQueryBuilder(t *testing.T) {

Convey("Query Builder", t, func() {

singleQ1, singleQ2 := new(idm.WorkspaceSingleQuery), new(idm.WorkspaceSingleQuery)

singleQ1.Label = "workspace1"
singleQ2.Label = "workspace2"

singleQ1Any, err := ptypes.MarshalAny(singleQ1)
So(err, ShouldBeNil)

singleQ2Any, err := ptypes.MarshalAny(singleQ2)
So(err, ShouldBeNil)

var singleQueries []*any.Any
singleQueries = append(singleQueries, singleQ1Any)
singleQueries = append(singleQueries, singleQ2Any)

simpleQuery := &service.Query{
SubQueries: singleQueries,
Operation: service.OperationType_OR,
Offset: 0,
Limit: 10,
}

s := sql.NewDAOQuery(simpleQuery, new(queryConverter)).String()
So(s, ShouldEqual, "(label='workspace1') OR (label='workspace2')")

})

Convey("Query Builder W/ subquery", t, func() {

singleQ1, singleQ2, singleQ3 := new(idm.WorkspaceSingleQuery), new(idm.WorkspaceSingleQuery), new(idm.WorkspaceSingleQuery)

singleQ1.Label = "workspace1"
singleQ2.Label = "workspace2"
singleQ3.Label = "workspace3"

singleQ1Any, err := ptypes.MarshalAny(singleQ1)
So(err, ShouldBeNil)

singleQ2Any, err := ptypes.MarshalAny(singleQ2)
So(err, ShouldBeNil)

singleQ3Any, err := ptypes.MarshalAny(singleQ3)
So(err, ShouldBeNil)

subQuery1 := &service.Query{
SubQueries: []*any.Any{singleQ1Any, singleQ2Any},
Operation: service.OperationType_OR,
}

subQuery2 := &service.Query{
SubQueries: []*any.Any{singleQ3Any},
}

subQuery1Any, err := ptypes.MarshalAny(subQuery1)
So(err, ShouldBeNil)

subQuery2Any, err := ptypes.MarshalAny(subQuery2)
So(err, ShouldBeNil)

composedQuery := &service.Query{
SubQueries: []*any.Any{
subQuery1Any,
subQuery2Any,
},
Offset: 0,
Limit: 10,
Operation: service.OperationType_AND,
}

s := sql.NewDAOQuery(composedQuery, new(queryConverter)).String()
So(s, ShouldEqual, "((label='workspace1') OR (label='workspace2')) AND (label='workspace3')")
})
}

func TestSearch(t *testing.T) {

Convey("Query Builder", t, func() {
Expand Down

0 comments on commit 01da219

Please sign in to comment.