temp_user_test.go 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package sqlstore
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. func TestTempUserCommandsAndQueries(t *testing.T) {
  8. Convey("Testing Temp User commands & queries", t, func() {
  9. InitTestDB(t)
  10. Convey("Given saved api key", func() {
  11. cmd := m.CreateTempUserCommand{
  12. OrgId: 2256,
  13. Name: "hello",
  14. Code: "asd",
  15. Email: "e@as.co",
  16. Status: m.TmpUserInvitePending,
  17. }
  18. err := CreateTempUser(&cmd)
  19. So(err, ShouldBeNil)
  20. Convey("Should be able to get temp users by org id", func() {
  21. query := m.GetTempUsersForOrgQuery{OrgId: 2256, Status: m.TmpUserInvitePending}
  22. err = GetTempUsersForOrg(&query)
  23. So(err, ShouldBeNil)
  24. So(len(query.Result), ShouldEqual, 1)
  25. })
  26. Convey("Should be able update status", func() {
  27. cmd2 := m.UpdateTempUserStatusCommand{Code: "asd", Status: m.TmpUserRevoked}
  28. err := UpdateTempUserStatus(&cmd2)
  29. So(err, ShouldBeNil)
  30. })
  31. })
  32. })
  33. }