diff --git a/internal/trainer/adapters/hour_firestore_repository.go b/internal/trainer/adapters/hour_firestore_repository.go index 89b3e12..8ee898a 100644 --- a/internal/trainer/adapters/hour_firestore_repository.go +++ b/internal/trainer/adapters/hour_firestore_repository.go @@ -27,7 +27,7 @@ func NewFirestoreHourRepository(firestoreClient *firestore.Client, hourFactory h return &FirestoreHourRepository{firestoreClient, hourFactory} } -func (f FirestoreHourRepository) GetOrCreateHour(ctx context.Context, time time.Time) (*hour.Hour, error) { +func (f FirestoreHourRepository) GetHour(ctx context.Context, time time.Time) (*hour.Hour, error) { date, err := f.getDateDTO( // getDateDTO should be used both for transactional and non transactional query, // the best way for that is to use closure diff --git a/internal/trainer/adapters/hour_memory_repository.go b/internal/trainer/adapters/hour_memory_repository.go index 9ea5eaf..8dee554 100644 --- a/internal/trainer/adapters/hour_memory_repository.go +++ b/internal/trainer/adapters/hour_memory_repository.go @@ -27,7 +27,7 @@ func NewMemoryHourRepository(hourFactory hour.Factory) *MemoryHourRepository { } } -func (m MemoryHourRepository) GetOrCreateHour(_ context.Context, hourTime time.Time) (*hour.Hour, error) { +func (m MemoryHourRepository) GetHour(_ context.Context, hourTime time.Time) (*hour.Hour, error) { m.lock.RLock() defer m.lock.RUnlock() diff --git a/internal/trainer/adapters/hour_mysql_repository.go b/internal/trainer/adapters/hour_mysql_repository.go index d48a5ac..d10533c 100644 --- a/internal/trainer/adapters/hour_mysql_repository.go +++ b/internal/trainer/adapters/hour_mysql_repository.go @@ -41,7 +41,7 @@ type sqlContextGetter interface { GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error } -func (m MySQLHourRepository) GetOrCreateHour(ctx context.Context, time time.Time) (*hour.Hour, error) { +func (m MySQLHourRepository) GetHour(ctx context.Context, time time.Time) (*hour.Hour, error) { return m.getOrCreateHour(ctx, m.db, time, false) } diff --git a/internal/trainer/adapters/hour_repository_test.go b/internal/trainer/adapters/hour_repository_test.go index a140c8e..2336c7b 100644 --- a/internal/trainer/adapters/hour_repository_test.go +++ b/internal/trainer/adapters/hour_repository_test.go @@ -222,7 +222,7 @@ func testUpdateHour_rollback(t *testing.T, repository hour.Repository) { }) require.Error(t, err) - persistedHour, err := repository.GetOrCreateHour(ctx, hourTime) + persistedHour, err := repository.GetHour(ctx, hourTime) require.NoError(t, err) assert.True(t, persistedHour.IsAvailable(), "availability change was persisted, not rolled back") @@ -336,7 +336,7 @@ func newValidHourTime() time.Time { func assertHourInRepository(ctx context.Context, t *testing.T, repo hour.Repository, hour *hour.Hour) { require.NotNil(t, hour) - hourFromRepo, err := repo.GetOrCreateHour(ctx, hour.Time()) + hourFromRepo, err := repo.GetHour(ctx, hour.Time()) require.NoError(t, err) assert.Equal(t, hour, hourFromRepo) diff --git a/internal/trainer/app/query/hour_availability.go b/internal/trainer/app/query/hour_availability.go index 0a7fa79..cda8af5 100644 --- a/internal/trainer/app/query/hour_availability.go +++ b/internal/trainer/app/query/hour_availability.go @@ -20,7 +20,7 @@ func NewHourAvailabilityHandler(hourRepo hour.Repository) HourAvailabilityHandle } func (h HourAvailabilityHandler) Handle(ctx context.Context, time time.Time) (bool, error) { - hour, err := h.hourRepo.GetOrCreateHour(ctx, time) + hour, err := h.hourRepo.GetHour(ctx, time) if err != nil { return false, err } diff --git a/internal/trainer/domain/hour/repository.go b/internal/trainer/domain/hour/repository.go index a31dc81..ebef424 100644 --- a/internal/trainer/domain/hour/repository.go +++ b/internal/trainer/domain/hour/repository.go @@ -6,7 +6,7 @@ import ( ) type Repository interface { - GetOrCreateHour(ctx context.Context, hourTime time.Time) (*Hour, error) + GetHour(ctx context.Context, hourTime time.Time) (*Hour, error) UpdateHour( ctx context.Context, hourTime time.Time,