Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
berejant committed Sep 27, 2024
1 parent ecd2d79 commit 2593021
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
18 changes: 9 additions & 9 deletions createdLessonsImporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
dekanatEvents "github.com/kneu-messenger-pigeon/dekanat-events"
"github.com/kneu-messenger-pigeon/events"
eventsMocks "github.com/kneu-messenger-pigeon/events/mocks"
"github.com/kneu-messenger-pigeon/fileStorage"
fileStorageMocks "github.com/kneu-messenger-pigeon/fileStorage/mocks"
"github.com/segmentio/kafka-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestExecuteImportCreatedLesson(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return([]byte{}, nil)
fileStorageMock.On("Set", uintToBytes(expectedEvent.Id)).Once().Return(nil)

Expand Down Expand Up @@ -182,7 +182,7 @@ func TestExecuteImportCreatedLesson(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(nil, nil)
fileStorageMock.On("Set", uintToBytes(expectedEvent.Id)).Once().Return(nil)

Expand Down Expand Up @@ -268,7 +268,7 @@ func TestExecuteImportCreatedLesson(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(nil, nil)
fileStorageMock.On("Set", uintToBytes(expectedEvent.Id)).Once().Return(nil)

Expand Down Expand Up @@ -359,7 +359,7 @@ func TestExecuteImportCreatedLesson(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(uintToBytes(lastLessonId), nil)
fileStorageMock.On("Set", uintToBytes(expectedEvent.Id)).Once().Return(nil)

Expand Down Expand Up @@ -417,7 +417,7 @@ func TestImportCreatedLesson(t *testing.T) {
db, dbMock, _ := sqlmock.New()
dbMock.ExpectBegin().WillReturnError(expectedError)

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(uintToBytes(lastLessonId), nil)

writerMock := eventsMocks.NewWriterInterface(t)
Expand Down Expand Up @@ -465,7 +465,7 @@ func TestGetMaxLessonId(t *testing.T) {
t.Run("Fail get max Lesson id", func(t *testing.T) {
expectedError := errors.New("expected error")

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(nil, expectedError)

createdLessonsImporter := &CreatedLessonsImporter{
Expand All @@ -487,7 +487,7 @@ func TestSetMaxLessonId(t *testing.T) {
expectedError := errors.New("expected error")
expectedLessonMaxId := uint(20)

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Set", uintToBytes(expectedLessonMaxId)).Once().Return(expectedError)

createdLessonsImporter := &CreatedLessonsImporter{
Expand All @@ -505,7 +505,7 @@ func TestSetMaxLessonId(t *testing.T) {
t.Run("Lesson max id chan", func(t *testing.T) {
expectedLessonMaxId := uint(50)

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Set", uintToBytes(expectedLessonMaxId)).Once().Return(nil)

createdLessonsImporter := &CreatedLessonsImporter{
Expand Down
10 changes: 5 additions & 5 deletions currentYearWatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"github.com/kneu-messenger-pigeon/events"
"github.com/kneu-messenger-pigeon/events/mocks"
"github.com/kneu-messenger-pigeon/fileStorage"
fileStorageMocks "github.com/kneu-messenger-pigeon/fileStorage/mocks"
"github.com/segmentio/kafka-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand All @@ -20,7 +20,7 @@ func TestExecuteCurrentYearWatcher(t *testing.T) {
var out bytes.Buffer

reader := mocks.NewReaderInterface(t)
storage := fileStorage.NewMockInterface(t)
storage := fileStorageMocks.NewInterface(t)
storage.On("Get").Return(nil, nil)

currentYearWatcher := CurrentYearWatcher{
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestExecuteCurrentYearWatcher(t *testing.T) {
}, nil)
reader.On("CommitMessages", matchContext, message).Return(expectedError)

storage := fileStorage.NewMockInterface(t)
storage := fileStorageMocks.NewInterface(t)
storage.On("Get").Return(uintToBytes(2024), nil)
storage.On(
"Set",
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestExecuteCurrentYearWatcher(t *testing.T) {
return message
}, expectedError)

storage := fileStorage.NewMockInterface(t)
storage := fileStorageMocks.NewInterface(t)
storage.On("Get").Return(uintToBytes(2024), nil)

currentYearWatcher := CurrentYearWatcher{
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestExecuteCurrentYearWatcher(t *testing.T) {
return message
}, nil)

storage := fileStorage.NewMockInterface(t)
storage := fileStorageMocks.NewInterface(t)
storage.On("Get").Return(uintToBytes(2024), nil)
storage.On(
"Set",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/joho/godotenv v1.4.0
github.com/kneu-messenger-pigeon/dekanat-events v0.1.10
github.com/kneu-messenger-pigeon/events v0.1.41
github.com/kneu-messenger-pigeon/fileStorage v1.1.2
github.com/kneu-messenger-pigeon/fileStorage v1.1.4
github.com/kneu-messenger-pigeon/victoria-metrics-init v0.1.2
github.com/mattn/go-sqlite3 v1.14.16
github.com/nakagami/firebirdsql v0.9.4
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ github.com/kneu-messenger-pigeon/fileStorage v1.1.1 h1:+UnSwQ2ADQq41WemAl0LvvGMY
github.com/kneu-messenger-pigeon/fileStorage v1.1.1/go.mod h1:v6IRKfG5C45B6Ls6781bmnLNwAE3e6ZcWuU0N55l66M=
github.com/kneu-messenger-pigeon/fileStorage v1.1.2 h1:kH8AklG9rTxF1t8+ZdjALizAXOh9QCYV1qEwk8pPTfA=
github.com/kneu-messenger-pigeon/fileStorage v1.1.2/go.mod h1:v6IRKfG5C45B6Ls6781bmnLNwAE3e6ZcWuU0N55l66M=
github.com/kneu-messenger-pigeon/fileStorage v1.1.3 h1:tb6u8VFxaQUfrV6NUdKjAmRX7T4QzPFLXHdrLwa17NE=
github.com/kneu-messenger-pigeon/fileStorage v1.1.3/go.mod h1:v6IRKfG5C45B6Ls6781bmnLNwAE3e6ZcWuU0N55l66M=
github.com/kneu-messenger-pigeon/fileStorage v1.1.4 h1:wFBmG9tQV2PBEwfsa3bWS1RnfHpK+bSsINmDrO34gbw=
github.com/kneu-messenger-pigeon/fileStorage v1.1.4/go.mod h1:v6IRKfG5C45B6Ls6781bmnLNwAE3e6ZcWuU0N55l66M=
github.com/kneu-messenger-pigeon/victoria-metrics-init v0.1.2 h1:jtKQpIefoZBJzgniS4+wM/HU+IgAPkhdOZa4B52RZA0=
github.com/kneu-messenger-pigeon/victoria-metrics-init v0.1.2/go.mod h1:HxDZwQUrMLgZNdLFT1llblZ7Zj6EBpBk7+9tcU4NZCk=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
Expand Down
14 changes: 7 additions & 7 deletions updatedScoresImporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
dekanatEvents "github.com/kneu-messenger-pigeon/dekanat-events"
"github.com/kneu-messenger-pigeon/events"
eventsMocks "github.com/kneu-messenger-pigeon/events/mocks"
"github.com/kneu-messenger-pigeon/fileStorage"
fileStorageMocks "github.com/kneu-messenger-pigeon/fileStorage/mocks"
"github.com/segmentio/kafka-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestExecuteImportUpdatedScores(t *testing.T) {

dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Times(2).Return(nil, nil)
fileStorageMock.On("Set", timeToBytes(expectedEvent.UpdatedAt)).Once().Return(nil)

Expand Down Expand Up @@ -226,7 +226,7 @@ func TestExecuteImportUpdatedScores(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(timeToBytes(lastRegDate), nil)

writerMock := eventsMocks.NewWriterInterface(t)
Expand Down Expand Up @@ -332,7 +332,7 @@ func TestExecuteImportUpdatedScores(t *testing.T) {
)
dbMock.ExpectRollback()

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(timeToBytes(lastRegDate), nil)
fileStorageMock.On(
"Set", timeToBytes(expectedEvent.UpdatedAt),
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestImportUpdatedScoresLesson(t *testing.T) {
db, dbMock, _ := sqlmock.New()
dbMock.ExpectBegin().WillReturnError(expectedError)

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(nil, nil)

writerMock := eventsMocks.NewWriterInterface(t)
Expand Down Expand Up @@ -476,7 +476,7 @@ func TestGetLastRegDate(t *testing.T) {
out.Reset()
expectedError := errors.New("expected error")

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On("Get").Once().Return(nil, expectedError)

updatedLessonsImporter := &UpdatedScoresImporter{
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestSetLastRegDate(t *testing.T) {
0, now.Location(),
).Add(-time.Minute * 10)

fileStorageMock := fileStorage.NewMockInterface(t)
fileStorageMock := fileStorageMocks.NewInterface(t)
fileStorageMock.On(
"Set", timeToBytes(newLastRegDate),
).Once().Return(expectedError)
Expand Down

0 comments on commit 2593021

Please sign in to comment.