apikey_test.go 636 B

12345678910111213141516171819202122232425262728293031
  1. package sqlstore
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. func TestApiKeyDataAccess(t *testing.T) {
  8. Convey("Testing API Key data access", t, func() {
  9. InitTestDB(t)
  10. Convey("Given saved api key", func() {
  11. cmd := m.AddApiKeyCommand{OrgId: 1, Name: "hello", Key: "asd"}
  12. err := AddApiKey(&cmd)
  13. So(err, ShouldBeNil)
  14. Convey("Should be able to get key by name", func() {
  15. query := m.GetApiKeyByNameQuery{KeyName: "hello", OrgId: 1}
  16. err = GetApiKeyByName(&query)
  17. So(err, ShouldBeNil)
  18. So(query.Result, ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }