2015-02-13 08:55:32 -06:00
|
|
|
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() {
|
2015-02-26 10:23:28 -06:00
|
|
|
cmd := m.AddApiKeyCommand{OrgId: 1, Name: "hello", Key: "asd"}
|
2015-02-13 08:55:32 -06:00
|
|
|
err := AddApiKey(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
2015-02-26 10:23:28 -06:00
|
|
|
Convey("Should be able to get key by name", func() {
|
|
|
|
query := m.GetApiKeyByNameQuery{KeyName: "hello", OrgId: 1}
|
|
|
|
err = GetApiKeyByName(&query)
|
2015-02-13 08:55:32 -06:00
|
|
|
|
2015-03-26 06:00:52 -05:00
|
|
|
So(err, ShouldBeNil)
|
2015-02-13 08:55:32 -06:00
|
|
|
So(query.Result, ShouldNotBeNil)
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|