Skip to content

Commit

Permalink
refactor: rename files and repository structs
Browse files Browse the repository at this point in the history
  • Loading branch information
flohansen committed Aug 4, 2024
1 parent cf32110 commit 50b1622
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func run() error {
}

grpcServer := grpc.NewServer()
store := repository.NewSQLite(db)
store := repository.NewFeatureSQLite(db)
notifier := feature.NewService(grpcServer, store)
migrator := repository.NewSQLMigrator(db)
routes := routes.New(store, notifier)
Expand Down
30 changes: 30 additions & 0 deletions internal/repository/feature_sqlite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:generate sqlc -f ../../sqlc.yaml generate

package repository

import (
"context"

"github.com/flohansen/dasher/internal/sqlc"
)

type FeatureSQLite struct {
q *sqlc.Queries
}

func NewFeatureSQLite(db sqlc.DBTX) *FeatureSQLite {
q := sqlc.New(db)
return &FeatureSQLite{q}
}

func (repo *FeatureSQLite) GetAll(ctx context.Context) ([]sqlc.Feature, error) {
return repo.q.GetAllFeatures(ctx)
}

func (repo *FeatureSQLite) Upsert(ctx context.Context, feature sqlc.Feature) error {
return repo.q.UpsertFeature(ctx, sqlc.UpsertFeatureParams(feature))
}

func (repo *FeatureSQLite) Delete(ctx context.Context, featureID string) error {
return repo.q.DeleteFeature(ctx, featureID)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
func TestSQLiteDatastore_Integration(t *testing.T) {
t.Run("given an empty database", func(t *testing.T) {
db := createTestDatabase(t)
store := NewSQLite(db.db)
store := NewFeatureSQLite(db.db)

db.init()

Expand All @@ -43,7 +43,7 @@ func TestSQLiteDatastore_Integration(t *testing.T) {

t.Run("given a database with a feature toggle", func(t *testing.T) {
db := createTestDatabase(t)
store := NewSQLite(db.db)
store := NewFeatureSQLite(db.db)

db.init()
db.insertFeature("FEATURE_TOGGLE_TEST")
Expand Down
30 changes: 0 additions & 30 deletions internal/repository/sqlite.go

This file was deleted.

File renamed without changes.

0 comments on commit 50b1622

Please sign in to comment.