Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 23, 2024
1 parent eefd452 commit 0143068
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/api/v2/controllers_ledgers_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func TestListLedgers(t *testing.T) {
name: "nominal",
expectQuery: ledgercontroller.NewListLedgersQuery(15),
returnData: []ledger.Ledger{
ledger.Must(ledger.NewWithDefaults(uuid.NewString())),
ledger.Must(ledger.NewWithDefaults(uuid.NewString())),
ledger.MustNewWithDefault(uuid.NewString()),
ledger.MustNewWithDefault(uuid.NewString()),
},
expectBackendCall: true,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/ledger/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestStats(t *testing.T) {
Return(10, nil)

ledgerController := NewDefaultController(
ledger.Must(ledger.NewWithDefaults("foo")),
ledger.MustNewWithDefault("foo"),
store,
NewMockListener(ctrl),
machineFactory,
Expand Down
8 changes: 4 additions & 4 deletions internal/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ func NewWithDefaults(name string) (*Ledger, error) {
return New(name, NewDefaultConfiguration())
}

// todo(libs): move in shared libs
func Must[V any](v *V, err error) V {
func MustNewWithDefault(name string) Ledger {
ledger, err := New(name, NewDefaultConfiguration())
if err != nil {
panic(err)
}
return *v
}
return *ledger
}
2 changes: 1 addition & 1 deletion internal/storage/ledger/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func newLedgerStore(t T) *Store {

require.NoError(t, systemstore.Migrate(ctx, db))

l := ledger.Must(ledger.NewWithDefaults(ledgerName))
l := ledger.MustNewWithDefault(ledgerName)
l.Bucket = ledgerName

b := bucket.New(db, ledgerName)
Expand Down

0 comments on commit 0143068

Please sign in to comment.