-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmanagement_test.go
More file actions
52 lines (47 loc) · 2.85 KB
/
management_test.go
File metadata and controls
52 lines (47 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package routes_test
import (
"github.com/rsksmart/liquidity-provider-server/internal/adapters/entrypoints/rest/routes"
"github.com/rsksmart/liquidity-provider-server/internal/configuration/environment"
"github.com/rsksmart/liquidity-provider-server/internal/usecases/liquidity_provider"
"github.com/rsksmart/liquidity-provider-server/internal/usecases/pegin"
"github.com/rsksmart/liquidity-provider-server/internal/usecases/pegout"
"github.com/rsksmart/liquidity-provider-server/test"
"github.com/rsksmart/liquidity-provider-server/test/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
"strings"
"testing"
)
func TestGetManagementEndpoints(t *testing.T) {
registryMock := &mocks.UseCaseRegistryMock{}
registryMock.EXPECT().GetPeginCollateralUseCase().Return(&pegin.GetCollateralUseCase{})
registryMock.EXPECT().AddPeginCollateralUseCase().Return(&pegin.AddCollateralUseCase{})
registryMock.EXPECT().GetPegoutCollateralUseCase().Return(&pegout.GetCollateralUseCase{})
registryMock.EXPECT().AddPegoutCollateralUseCase().Return(&pegout.AddCollateralUseCase{})
registryMock.EXPECT().ChangeStatusUseCase().Return(&liquidity_provider.ChangeStatusUseCase{})
registryMock.EXPECT().ResignationUseCase().Return(&liquidity_provider.ResignUseCase{})
registryMock.EXPECT().WithdrawCollateralUseCase().Return(&liquidity_provider.WithdrawCollateralUseCase{})
registryMock.EXPECT().GetConfigurationUseCase().Return(&liquidity_provider.GetConfigUseCase{})
registryMock.EXPECT().SetGeneralConfigUseCase().Return(&liquidity_provider.SetGeneralConfigUseCase{})
registryMock.EXPECT().SetPeginConfigUseCase().Return(&liquidity_provider.SetPeginConfigUseCase{})
registryMock.EXPECT().SetPegoutConfigUseCase().Return(&liquidity_provider.SetPegoutConfigUseCase{})
registryMock.EXPECT().SetCredentialsUseCase().Return(&liquidity_provider.SetCredentialsUseCase{})
registryMock.EXPECT().LoginUseCase().Return(&liquidity_provider.LoginUseCase{})
registryMock.EXPECT().GetManagementUiDataUseCase().Return(&liquidity_provider.GetManagementUiDataUseCase{})
registryMock.EXPECT().GetPeginReportUseCase().Return(&pegin.GetPeginReportUseCase{})
registryMock.EXPECT().GetPegoutReportUseCase().Return(&pegout.GetPegoutReportUseCase{})
endpoints := routes.GetManagementEndpoints(environment.Environment{}, registryMock, &mocks.StoreMock{})
specBytes := test.ReadFile(t, "OpenApi.yml")
spec := &openApiSpecification{}
err := yaml.Unmarshal(specBytes, spec)
require.NoError(t, err)
assert.Len(t, endpoints, 19)
for _, endpoint := range endpoints {
if endpoint.Path != routes.IconPath && endpoint.Path != routes.StaticPath {
lowerCaseMethod := strings.ToLower(endpoint.Method)
assert.NotNilf(t, spec.Paths[endpoint.Path][lowerCaseMethod], "Handler not found for path %s and verb %s", endpoint.Path, endpoint.Method)
}
}
registryMock.AssertExpectations(t)
}