mirror of
https://github.com/grafana/grafana.git
synced 2025-01-21 22:13:38 -06:00
8b0dd4244b
* Search: Fixes search limits and adds a page parameter This adds a page parameter to search api without adding any major breaking change. It does at an api validation error when trying to use a limit beyond 5000. This is a breaking change. We could remove this and have it only in the docs and describe that this is a limit that grafana will apply silently. Fixes #16049 * Fix: Corrected wrong array slice change * Docs: minor docs fix * Search: fixed folder tests * Fixed: Moved limit to correct inner query * Search: moving limit check and page check * Search: limit in handler is no longer needed
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package sqlstore
|
|
|
|
import (
|
|
"testing"
|
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestSearchBuilder(t *testing.T) {
|
|
Convey("Testing building a search", t, func() {
|
|
signedInUser := &m.SignedInUser{
|
|
OrgId: 1,
|
|
UserId: 1,
|
|
}
|
|
|
|
sb := NewSearchBuilder(signedInUser, 1000, 0, m.PERMISSION_VIEW)
|
|
|
|
Convey("When building a normal search", func() {
|
|
sql, params := sb.IsStarred().WithTitle("test").ToSql()
|
|
So(sql, ShouldStartWith, "SELECT")
|
|
So(sql, ShouldContainSubstring, "INNER JOIN dashboard on ids.id = dashboard.id")
|
|
So(sql, ShouldContainSubstring, "ORDER BY dashboard.title ASC")
|
|
So(len(params), ShouldBeGreaterThan, 0)
|
|
})
|
|
|
|
Convey("When building a search with tag filter", func() {
|
|
sql, params := sb.WithTags([]string{"tag1", "tag2"}).ToSql()
|
|
So(sql, ShouldStartWith, "SELECT")
|
|
So(sql, ShouldContainSubstring, "LEFT OUTER JOIN dashboard_tag")
|
|
So(sql, ShouldContainSubstring, "ORDER BY dashboard.title ASC")
|
|
So(len(params), ShouldBeGreaterThan, 0)
|
|
})
|
|
})
|
|
}
|