Provisioning: Fix regression when dashboardProvisioner is accessed before being initialised (#85011)
* Provisioning: Fix regression when dashboardProvisioner is accessed before being initialized * Set dashboard provisioner in the provider
This commit is contained in:
@@ -7,18 +7,18 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
dashboardstore "github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/provisioning/utils"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func TestProvisioningServiceImpl(t *testing.T) {
|
||||
t.Run("Restart dashboard provisioning and stop service", func(t *testing.T) {
|
||||
serviceTest := setup()
|
||||
serviceTest := setup(t)
|
||||
err := serviceTest.service.ProvisionDashboards(context.Background())
|
||||
assert.Nil(t, err)
|
||||
serviceTest.startService()
|
||||
@@ -45,7 +45,7 @@ func TestProvisioningServiceImpl(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Failed reloading does not stop polling with old provisioned", func(t *testing.T) {
|
||||
serviceTest := setup()
|
||||
serviceTest := setup(t)
|
||||
err := serviceTest.service.ProvisionDashboards(context.Background())
|
||||
assert.Nil(t, err)
|
||||
serviceTest.startService()
|
||||
@@ -83,7 +83,7 @@ type serviceTestStruct struct {
|
||||
service *ProvisioningServiceImpl
|
||||
}
|
||||
|
||||
func setup() *serviceTestStruct {
|
||||
func setup(t *testing.T) *serviceTestStruct {
|
||||
serviceTest := &serviceTestStruct{}
|
||||
serviceTest.waitTimeout = time.Second
|
||||
|
||||
@@ -102,7 +102,8 @@ func setup() *serviceTestStruct {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
serviceTest.service.Cfg = setting.NewCfg()
|
||||
err := serviceTest.service.setDashboardProvisioner()
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
serviceTest.cancel = cancel
|
||||
|
||||
Reference in New Issue
Block a user