Skip to content

Commit

Permalink
fix(core.History): fix null datasets in repsonses
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Nov 28, 2017
1 parent a8fd2ec commit ab1fd7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
12 changes: 11 additions & 1 deletion core/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ func (d *QueryRequests) List(p *ListParams, res *[]*repo.DatasetRef) error {
ref.Dataset = ds
}
}
*res = results

// TODO - clean this up, this is a hack to prevent null datasets from
// being sent back as responses.
// Warning - this could throw off pagination :/
final := []*repo.DatasetRef{}
for _, ref := range results {
if ref.Dataset != nil {
final = append(final, ref)
}
}
*res = final
return nil
}

Expand Down
18 changes: 9 additions & 9 deletions core/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ func TestDatasetQueries(t *testing.T) {
return
}

ns, err := mr.Namespace(30, 0)
if err != nil {
t.Errorf("error getting repo namespace: %s", err.Error())
return
}
// ns, err := mr.Namespace(30, 0)
// if err != nil {
// t.Errorf("error getting repo namespace: %s", err.Error())
// return
// }

for _, n := range ns {
fmt.Println(n)
}
// for _, n := range ns {
// fmt.Println(n)
// }

qres := &repo.DatasetRef{}
if err = req.Run(&RunParams{
Expand All @@ -160,7 +160,7 @@ func TestDatasetQueries(t *testing.T) {
err string
}{
{&DatasetQueriesParams{}, []*repo.DatasetRef{}, "path is required"},
{&DatasetQueriesParams{Path: path.String()}, []*repo.DatasetRef{}, ""},
{&DatasetQueriesParams{Path: path.String()}, []*repo.DatasetRef{&repo.DatasetRef{}}, ""},
// TODO: add more tests
}

Expand Down
2 changes: 1 addition & 1 deletion repo/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestDatasetQueries(t *testing.T) {
}

qs := DatasetQueries(node)
expect := 1
expect := 2
if len(qs) != expect {
t.Errorf("query count mismatch, expected: %d, got: %d", expect, len(qs))
}
Expand Down

0 comments on commit ab1fd7c

Please sign in to comment.