mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* sqlstore: Run tests as integration tests * Truncate database instead of re-creating it on each test * Fix test description See https://github.com/grafana/grafana/pull/12129 * Fix lint issues * Fix postgres dialect after review suggestion * Rename and document functions after review suggestion * Add periods * Fix auto-increment value for mysql dialect Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
43 lines
950 B
Go
43 lines
950 B
Go
// +build integration
|
|
|
|
package sqlstore
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestUserStarsDataAccess(t *testing.T) {
|
|
Convey("Testing User Stars Data Access", t, func() {
|
|
InitTestDB(t)
|
|
|
|
Convey("Given saved star", func() {
|
|
cmd := models.StarDashboardCommand{
|
|
DashboardId: 10,
|
|
UserId: 12,
|
|
}
|
|
|
|
err := StarDashboard(&cmd)
|
|
So(err, ShouldBeNil)
|
|
|
|
Convey("IsStarredByUser should return true when starred", func() {
|
|
query := models.IsStarredByUserQuery{UserId: 12, DashboardId: 10}
|
|
err := IsStarredByUser(&query)
|
|
So(err, ShouldBeNil)
|
|
|
|
So(query.Result, ShouldBeTrue)
|
|
})
|
|
|
|
Convey("IsStarredByUser should return false when not starred", func() {
|
|
query := models.IsStarredByUserQuery{UserId: 12, DashboardId: 12}
|
|
err := IsStarredByUser(&query)
|
|
So(err, ShouldBeNil)
|
|
|
|
So(query.Result, ShouldBeFalse)
|
|
})
|
|
})
|
|
})
|
|
}
|