grafana/pkg/services/supportbundles/bundleregistry/service_test.go
Jo f9163351fd
Support bundles: Refactor registry into separate service (#62945)
* add bundle registry service to avoid dependency cycles

* move user support bundle collector to user service

* move usage stat bundle implementation to usage stats

* add info for background service

* fix remaining imports

* whitespace
2023-02-06 17:50:03 +01:00

37 lines
889 B
Go

package bundleregistry
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/services/supportbundles"
)
func TestService_RegisterSupportItemCollector(t *testing.T) {
s := ProvideService()
collector := supportbundles.Collector{
UID: "test",
DisplayName: "test",
Description: "test",
IncludedByDefault: true,
Default: true,
Fn: func(context.Context) (*supportbundles.SupportItem, error) {
return nil, nil
},
}
t.Run("should register collector", func(t *testing.T) {
s.RegisterSupportItemCollector(collector)
require.Len(t, s.collectors, 1)
require.Len(t, s.Collectors(), 1)
})
t.Run("should not register collector with same UID", func(t *testing.T) {
s.RegisterSupportItemCollector(collector)
require.Len(t, s.collectors, 1)
require.Len(t, s.Collectors(), 1)
})
}