mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 11:44:26 -06:00
8677552dda
* refactor: renaming service-accounts to serviceAccounts * refactor: renaming service-accounts to serviceAccounts in docs * tests
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package manager
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/services/serviceaccounts/tests"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestProvideServiceAccount_DeleteServiceAccount(t *testing.T) {
|
|
t.Run("feature toggle present, should call store function", func(t *testing.T) {
|
|
storeMock := &tests.ServiceAccountsStoreMock{Calls: tests.Calls{}}
|
|
svc := ServiceAccountsService{
|
|
features: featuremgmt.WithFeatures("serviceAccounts", true),
|
|
store: storeMock}
|
|
err := svc.DeleteServiceAccount(context.Background(), 1, 1)
|
|
require.NoError(t, err)
|
|
assert.Len(t, storeMock.Calls.DeleteServiceAccount, 1)
|
|
})
|
|
|
|
t.Run("no feature toggle present, should not call store function", func(t *testing.T) {
|
|
svcMock := &tests.ServiceAccountsStoreMock{Calls: tests.Calls{}}
|
|
svc := ServiceAccountsService{
|
|
features: featuremgmt.WithFeatures("serviceAccounts", false),
|
|
store: svcMock,
|
|
log: log.New("serviceaccounts-manager-test"),
|
|
}
|
|
err := svc.DeleteServiceAccount(context.Background(), 1, 1)
|
|
require.NoError(t, err)
|
|
assert.Len(t, svcMock.Calls.DeleteServiceAccount, 0)
|
|
})
|
|
}
|