Skip to content

Commit

Permalink
Fix nil panic in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Sep 5, 2024
1 parent deaa7c1 commit da78a49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/ban/ban_steam_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s banSteamUsecase) GetByLastIP(ctx context.Context, lastIP netip.Addr, del
func (s banSteamUsecase) Save(ctx context.Context, ban *domain.BanSteam) error {
oldState := domain.Open
if ban.BanID > 0 {
existing, errExisting := s.GetByBanID(ctx, ban.BanID, false, false)
existing, errExisting := s.GetByBanID(ctx, ban.BanID, true, true)
if errExisting != nil {
slog.Error("Failed to get existing ban", log.ErrAttr(errExisting))

Expand Down
9 changes: 4 additions & 5 deletions internal/test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/leighmacdonald/gbans/internal/notification"
"io"
"log/slog"
"net"
Expand Down Expand Up @@ -34,7 +35,6 @@ import (
"github.com/leighmacdonald/gbans/internal/match"
"github.com/leighmacdonald/gbans/internal/network"
"github.com/leighmacdonald/gbans/internal/news"
"github.com/leighmacdonald/gbans/internal/notification"
"github.com/leighmacdonald/gbans/internal/patreon"
"github.com/leighmacdonald/gbans/internal/person"
"github.com/leighmacdonald/gbans/internal/report"
Expand Down Expand Up @@ -132,13 +132,12 @@ func TestMain(m *testing.M) {
newsUC = news.NewNewsUsecase(news.NewNewsRepository(databaseConn))
serversUC = servers.NewServersUsecase(servers.NewServersRepository(databaseConn))
wikiUC = wiki.NewWikiUsecase(wiki.NewWikiRepository(databaseConn))

notificationUC = notification.NewNotificationUsecase(notification.NewNotificationRepository(databaseConn), discordUC)
patreonUC = patreon.NewPatreonUsecase(patreon.NewPatreonRepository(databaseConn), configUC)
personUC = person.NewPersonUsecase(person.NewPersonRepository(conf, databaseConn), configUC)
wordFilterUC = wordfilter.NewWordFilterUsecase(wordfilter.NewWordFilterRepository(databaseConn), nil)
forumUC = forum.NewForumUsecase(forum.NewForumRepository(databaseConn), nil)
wordFilterUC = wordfilter.NewWordFilterUsecase(wordfilter.NewWordFilterRepository(databaseConn), notificationUC)
forumUC = forum.NewForumUsecase(forum.NewForumRepository(databaseConn), notificationUC)

notificationUC = notification.NewNotificationUsecase(notification.NewNotificationRepository(databaseConn), discordUC)
stateUC = state.NewStateUsecase(eventBroadcaster, state.NewStateRepository(state.NewCollector(serversUC)), configUC, serversUC)

networkUC = network.NewNetworkUsecase(eventBroadcaster, network.NewNetworkRepository(databaseConn), personUC, configUC)
Expand Down

0 comments on commit da78a49

Please sign in to comment.