json_index_test.go 768 B

1234567891011121314151617181920212223242526272829303132333435
  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: "", Tag: "", 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", Tag: "", Limit: 20})
  20. So(err, ShouldBeNil)
  21. So(len(res), ShouldEqual, 1)
  22. So(res[0].Title, ShouldEqual, "Home")
  23. })
  24. })
  25. }