The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/provisioning/utils/utils_test.go

31 lines
797 B

package utils
import (
"context"
"testing"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/stretchr/testify/require"
)
func TestCheckOrgExists(t *testing.T) {
t.Run("with default org in database", func(t *testing.T) {
sqlstore.InitTestDB(t)
defaultOrg := models.CreateOrgCommand{Name: "Main Org."}
err := sqlstore.CreateOrg(context.Background(), &defaultOrg)
require.NoError(t, err)
t.Run("default org exists", func(t *testing.T) {
err := CheckOrgExists(context.Background(), defaultOrg.Result.Id)
require.NoError(t, err)
})
t.Run("other org doesn't exist", func(t *testing.T) {
err := CheckOrgExists(context.Background(), defaultOrg.Result.Id+1)
require.Equal(t, err, models.ErrOrgNotFound)
})
})
}