MCPcopy Create free account
hub / github.com/clouditor/clouditor / TestService_cacheControls

Function TestService_cacheControls

service/evaluation/evaluation_test.go:1531–1614  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1529}
1530
1531func TestService_cacheControls(t *testing.T) {
1532 type fields struct {
1533 UnimplementedEvaluationServer evaluation.UnimplementedEvaluationServer
1534 orchestrator *api.RPCConnection[orchestrator.OrchestratorClient]
1535 scheduler *gocron.Scheduler
1536 authz service.AuthorizationStrategy
1537 storage persistence.Storage
1538 catalogControls map[string]map[string]*orchestrator.Control
1539 }
1540 type args struct {
1541 catalogId string
1542 }
1543 tests := []struct {
1544 name string
1545 fields fields
1546 args args
1547 wantSvc assert.Want[*Service]
1548 wantErr assert.ErrorAssertionFunc
1549 }{
1550 {
1551 name: "catalog_id missing",
1552 wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
1553 return assert.ErrorIs(t, err, ErrCatalogIdIsMissing)
1554 },
1555 },
1556 {
1557 name: "initOrchestratorClient fails",
1558 fields: fields{
1559 orchestrator: api.NewRPCConnection(testdata.MockGRPCTarget, orchestrator.NewOrchestratorClient, grpc.WithContextDialer(connectionRefusedDialer)),
1560 },
1561 args: args{
1562 catalogId: testdata.MockCatalogID,
1563 },
1564 wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
1565 return assert.ErrorContains(t, err, "connection refused")
1566 },
1567 },
1568 {
1569 name: "no controls available",
1570 fields: fields{
1571 orchestrator: api.NewRPCConnection(testdata.MockGRPCTarget, orchestrator.NewOrchestratorClient, grpc.WithContextDialer(newBufConnDialer(testutil.NewInMemoryStorage(t, func(s persistence.Storage) {})))),
1572 catalogControls: make(map[string]map[string]*orchestrator.Control),
1573 },
1574 args: args{
1575 catalogId: testdata.MockCatalogID,
1576 },
1577 wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
1578 return assert.ErrorContains(t, err, fmt.Sprintf("no controls for catalog '%s' available", testdata.MockCatalogID))
1579 },
1580 },
1581 {
1582 name: "Happy path",
1583 fields: fields{
1584 orchestrator: api.NewRPCConnection(testdata.MockGRPCTarget, orchestrator.NewOrchestratorClient, grpc.WithContextDialer(newBufConnDialer(testutil.NewInMemoryStorage(t, func(s persistence.Storage) {
1585 assert.NoError(t, s.Create(orchestratortest.NewCatalog()))
1586 })))),
1587 catalogControls: make(map[string]map[string]*orchestrator.Control),
1588 },

Callers

nothing calls this directly

Calls 8

cacheControlsMethod · 0.95
NewRPCConnectionFunction · 0.92
NewInMemoryStorageFunction · 0.92
NewCatalogFunction · 0.92
EqualFunction · 0.92
OptionalFunction · 0.92
newBufConnDialerFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected