From a717e856c5a87d32b7624e66ab60742e7456bfd3 Mon Sep 17 00:00:00 2001 From: Emil Hessman <248952+ceh@users.noreply.github.com> Date: Mon, 9 Nov 2020 08:13:06 +0100 Subject: [PATCH] Chore: Rewrite test in GoConvey to stdlib and testify (#28918) --- pkg/services/sqlstore/playlist_test.go | 49 ++++++++++++-------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/pkg/services/sqlstore/playlist_test.go b/pkg/services/sqlstore/playlist_test.go index c5373366389..45c951de2de 100644 --- a/pkg/services/sqlstore/playlist_test.go +++ b/pkg/services/sqlstore/playlist_test.go @@ -5,41 +5,36 @@ package sqlstore import ( "testing" - . "github.com/smartystreets/goconvey/convey" - "github.com/grafana/grafana/pkg/models" + "github.com/stretchr/testify/require" ) func TestPlaylistDataAccess(t *testing.T) { - Convey("Testing Playlist data access", t, func() { - InitTestDB(t) + InitTestDB(t) - Convey("Can create playlist", func() { + t.Run("Can create playlist", func(t *testing.T) { + items := []models.PlaylistItemDTO{ + {Title: "graphite", Value: "graphite", Type: "dashboard_by_tag"}, + {Title: "Backend response times", Value: "3", Type: "dashboard_by_id"}, + } + cmd := models.CreatePlaylistCommand{Name: "NYC office", Interval: "10m", OrgId: 1, Items: items} + err := CreatePlaylist(&cmd) + require.NoError(t, err) + + t.Run("Can update playlist", func(t *testing.T) { items := []models.PlaylistItemDTO{ - {Title: "graphite", Value: "graphite", Type: "dashboard_by_tag"}, - {Title: "Backend response times", Value: "3", Type: "dashboard_by_id"}, + {Title: "influxdb", Value: "influxdb", Type: "dashboard_by_tag"}, + {Title: "Backend response times", Value: "2", Type: "dashboard_by_id"}, } - cmd := models.CreatePlaylistCommand{Name: "NYC office", Interval: "10m", OrgId: 1, Items: items} - err := CreatePlaylist(&cmd) - So(err, ShouldBeNil) + query := models.UpdatePlaylistCommand{Name: "NYC office ", OrgId: 1, Id: 1, Interval: "10s", Items: items} + err = UpdatePlaylist(&query) + require.NoError(t, err) + }) - Convey("can update playlist", func() { - items := []models.PlaylistItemDTO{ - {Title: "influxdb", Value: "influxdb", Type: "dashboard_by_tag"}, - {Title: "Backend response times", Value: "2", Type: "dashboard_by_id"}, - } - query := models.UpdatePlaylistCommand{Name: "NYC office ", OrgId: 1, Id: 1, Interval: "10s", Items: items} - err = UpdatePlaylist(&query) - - So(err, ShouldBeNil) - - Convey("can remove playlist", func() { - query := models.DeletePlaylistCommand{Id: 1} - err = DeletePlaylist(&query) - - So(err, ShouldBeNil) - }) - }) + t.Run("Can remove playlist", func(t *testing.T) { + query := models.DeletePlaylistCommand{Id: 1} + err = DeletePlaylist(&query) + require.NoError(t, err) }) }) }