From a88187023dc1d704e92255c34b268bf267f793ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 13 Feb 2015 15:55:32 +0100 Subject: [PATCH] Added a sql integration test for api keys --- pkg/services/sqlstore/apikey_test.go | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkg/services/sqlstore/apikey_test.go diff --git a/pkg/services/sqlstore/apikey_test.go b/pkg/services/sqlstore/apikey_test.go new file mode 100644 index 00000000000..de31b6c1d1d --- /dev/null +++ b/pkg/services/sqlstore/apikey_test.go @@ -0,0 +1,31 @@ +package sqlstore + +import ( + "testing" + + . "github.com/smartystreets/goconvey/convey" + + m "github.com/grafana/grafana/pkg/models" +) + +func TestApiKeyDataAccess(t *testing.T) { + + Convey("Testing API Key data access", t, func() { + InitTestDB(t) + + Convey("Given saved api key", func() { + cmd := m.AddApiKeyCommand{AccountId: 1, Key: "hello"} + err := AddApiKey(&cmd) + So(err, ShouldBeNil) + + Convey("Should be able to get key by key", func() { + query := m.GetApiKeyByKeyQuery{Key: "hello"} + err = GetApiKeyByKey(&query) + So(err, ShouldBeNil) + + So(query.Result, ShouldNotBeNil) + }) + + }) + }) +}