json_index_test.go 944 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package search
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. func TestJsonDashIndex(t *testing.T) {
  7. Convey("Given the json dash index", t, func() {
  8. index := NewJsonDashIndex("../../../public/dashboards/")
  9. Convey("Should be able to update index", func() {
  10. err := index.updateIndex()
  11. So(err, ShouldBeNil)
  12. })
  13. Convey("Should be able to search index", func() {
  14. res, err := index.Search(&Query{Title: "", Limit: 20})
  15. So(err, ShouldBeNil)
  16. So(len(res), ShouldEqual, 3)
  17. })
  18. Convey("Should be able to search index by title", func() {
  19. res, err := index.Search(&Query{Title: "home", Limit: 20})
  20. So(err, ShouldBeNil)
  21. So(len(res), ShouldEqual, 1)
  22. So(res[0].Title, ShouldEqual, "Home")
  23. })
  24. Convey("Should not return when starred is filtered", func() {
  25. res, err := index.Search(&Query{Title: "", IsStarred: true})
  26. So(err, ShouldBeNil)
  27. So(len(res), ShouldEqual, 0)
  28. })
  29. })
  30. }