tripnomics_7.5.5/pkg/services/provisioning/utils/utils_test.go
venbatechnologies@gmail.com 91fce5c4bf Initial commit
2021-07-05 13:49:40 +05:30

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)
})
})
}