mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Provisioning: Check that org. from config exists Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix some code after applying suggestions Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Add negative test case Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
30 lines
691 B
Go
30 lines
691 B
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestCheckOrgExists(t *testing.T) {
|
|
Convey("with default org in database", t, func() {
|
|
sqlstore.InitTestDB(t)
|
|
|
|
defaultOrg := models.CreateOrgCommand{Name: "Main Org."}
|
|
err := sqlstore.CreateOrg(&defaultOrg)
|
|
So(err, ShouldBeNil)
|
|
|
|
Convey("default org exists", func() {
|
|
err := CheckOrgExists(defaultOrg.Result.Id)
|
|
So(err, ShouldBeNil)
|
|
})
|
|
|
|
Convey("other org doesn't exist", func() {
|
|
err := CheckOrgExists(defaultOrg.Result.Id + 1)
|
|
So(err, ShouldEqual, models.ErrOrgNotFound)
|
|
})
|
|
})
|
|
}
|