-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented skipping transactions instead of failing with fatal error…
… details of which cannot be fetched refactoring added interfaces for tests
- Loading branch information
Dovlet Hojayev
committed
Jun 6, 2024
1 parent
9f34c69
commit cf3a9d2
Showing
16 changed files
with
378 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package portfoliodownloader_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/stretchr/testify/assert" | ||
"go.uber.org/mock/gomock" | ||
|
||
"github.com/dhojayev/traderepublic-portfolio-downloader/cmd/portfoliodownloader" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/api/timeline/details" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/api/timeline/transactions" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/api/websocket" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/filesystem" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/portfolio" | ||
"github.com/dhojayev/traderepublic-portfolio-downloader/internal/portfolio/transaction" | ||
) | ||
|
||
func TestApp_Run(t *testing.T) { | ||
t.Parallel() | ||
|
||
logger := log.New() | ||
ctrl := gomock.NewController(t) | ||
transactionsClientMock := transactions.NewMockClientInterface(ctrl) | ||
detailsReaderMock := portfolio.NewMockReaderInterface(ctrl) | ||
typeResolverMock := transactions.NewMockEventTypeResolverInterface(ctrl) | ||
processorMock := transaction.NewMockProcessorInterface(ctrl) | ||
|
||
detailsClient := details.NewClient(detailsReaderMock) | ||
app := portfoliodownloader.NewApp(transactionsClientMock, typeResolverMock, detailsClient, processorMock, logger) | ||
|
||
transactionsClientMock. | ||
EXPECT(). | ||
Get(). | ||
Return([]transactions.ResponseItem{ | ||
{ | ||
Action: transactions.ResponseItemAction{ | ||
Payload: "0e5cf3cb-0f4d-4905-ae5f-ec0a530de6ca", | ||
Type: "timelineDetail", | ||
}, | ||
ID: "0e5cf3cb-0f4d-4905-ae5f-ec0a530de6ca", | ||
}, | ||
}, nil) | ||
|
||
detailsReaderMock. | ||
EXPECT(). | ||
Read(details.DataType, map[string]any{"id": "0e5cf3cb-0f4d-4905-ae5f-ec0a530de6ca"}). | ||
Return(filesystem.OutputData{}, fmt.Errorf("could not fetch %s: %w", details.DataType, websocket.ErrErrorStateReceived)) | ||
|
||
err := app.Run() | ||
|
||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.