grafana/pkg/services/sqlstore/stars_test.go
Carl Bergquist b40e78a943
Instrumentation: add context.Context to the dashboard get flow. (#34955)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-06-15 16:08:27 +02:00

44 lines
1011 B
Go

// +build integration
package sqlstore
import (
"context"
"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 := IsStarredByUserCtx(context.Background(), &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 := IsStarredByUserCtx(context.Background(), &query)
So(err, ShouldBeNil)
So(query.Result, ShouldBeFalse)
})
})
})
}