Skip to content

Commit

Permalink
Rename GetOrCreateHour to GetHour in trainer domain repository
Browse files Browse the repository at this point in the history
  • Loading branch information
roblaszczak committed Sep 28, 2020
1 parent 8d92748 commit 22c0a25
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/trainer/adapters/hour_firestore_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/trainer/adapters/hour_memory_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion internal/trainer/adapters/hour_mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/trainer/adapters/hour_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/trainer/app/query/hour_availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/trainer/domain/hour/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 22c0a25

Please sign in to comment.