From e65f1f32a79153ce6672302dca0f894e7fae4ec4 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Wed, 24 Aug 2022 13:18:08 +0000 Subject: [PATCH] chore(session): Remove repository method that was only used in tests This unexported method was only used by a single test, and was taking advantage of its implmentation to populate Connections rather than Sessions. This repository should only interact with Sessions, since there is a separate repository for Connections. --- internal/session/job_session_cleanup_test.go | 2 +- internal/session/repository.go | 24 -------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/internal/session/job_session_cleanup_test.go b/internal/session/job_session_cleanup_test.go index 8017c24f59..c65b454432 100644 --- a/internal/session/job_session_cleanup_test.go +++ b/internal/session/job_session_cleanup_test.go @@ -306,7 +306,7 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) { t.Helper() var conns []*Connection - require.NoError(repo.list(ctx, &conns, "", nil)) + require.NoError(rw.SearchWhere(ctx, &conns, "", nil)) for i, connId := range connIds { var expected ConnectionStatus switch { diff --git a/internal/session/repository.go b/internal/session/repository.go index f43a48ba57..c09ed4b338 100644 --- a/internal/session/repository.go +++ b/internal/session/repository.go @@ -108,30 +108,6 @@ func (r *Repository) listPermissionWhereClauses() ([]string, []interface{}) { return where, args } -// list will return a listing of resources and honor the WithLimit option or the -// repo defaultLimit. Supports WithOrder option. -func (r *Repository) list(ctx context.Context, resources interface{}, where string, args []interface{}, opt ...Option) error { - const op = "session.(Repository).list" - opts := getOpts(opt...) - limit := r.defaultLimit - var dbOpts []db.Option - if opts.withLimit != 0 { - // non-zero signals an override of the default limit for the repo. - limit = opts.withLimit - } - dbOpts = append(dbOpts, db.WithLimit(limit)) - switch opts.withOrderByCreateTime { - case db.AscendingOrderBy: - dbOpts = append(dbOpts, db.WithOrder("create_time asc")) - case db.DescendingOrderBy: - dbOpts = append(dbOpts, db.WithOrder("create_time")) - } - if err := r.reader.SearchWhere(ctx, resources, where, args, dbOpts...); err != nil { - return errors.Wrap(ctx, err, op) - } - return nil -} - func (r *Repository) convertToSessions(ctx context.Context, sessionList []*sessionListView, opt ...Option) ([]*Session, error) { const op = "session.(Repository).convertToSessions" opts := getOpts(opt...)