parent
f07451351b
commit
8087f5ba7b
|
@ -1,12 +1,12 @@
|
|||
repos:
|
||||
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
|
||||
rev: v9.10.0
|
||||
rev: v9.11.0
|
||||
hooks:
|
||||
- id: commitlint
|
||||
stages: [commit-msg]
|
||||
additional_dependencies: ["@commitlint/config-conventional"]
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v1.55.2
|
||||
rev: v1.56.1
|
||||
hooks:
|
||||
- id: golangci-lint
|
||||
- repo: https://github.com/hadolint/hadolint
|
||||
|
@ -14,7 +14,7 @@ repos:
|
|||
hooks:
|
||||
- id: hadolint
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.33.0
|
||||
rev: v1.34.0
|
||||
hooks:
|
||||
- id: yamllint
|
||||
args: [--strict, -c=./.yamllint.yml]
|
||||
|
|
|
@ -7,7 +7,7 @@ when:
|
|||
- ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
||||
variables:
|
||||
- &go_image 'golang:1.21'
|
||||
- &go_image 'golang:1.22'
|
||||
|
||||
steps:
|
||||
govulncheck:
|
||||
|
|
|
@ -18,7 +18,7 @@ services:
|
|||
RABBITMQ_DEFAULT_PASS: twhelp
|
||||
|
||||
variables:
|
||||
- &go_image 'golang:1.21'
|
||||
- &go_image 'golang:1.22'
|
||||
|
||||
steps:
|
||||
generate:
|
||||
|
@ -41,7 +41,7 @@ steps:
|
|||
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
lint:
|
||||
image: golangci/golangci-lint:v1.55
|
||||
image: golangci/golangci-lint:v1.56
|
||||
pull: true
|
||||
depends_on:
|
||||
- generate
|
||||
|
|
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ install-git-hooks:
|
|||
.PHONY: install-golangci-lint
|
||||
install-golangci-lint:
|
||||
@echo "Installing github.com/golangci/golangci-lint..."
|
||||
@(test -f $(GOLANGCI_LINT_PATH) && echo "github.com/golangci/golangci-lint is already installed. Skipping...") || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.55.2
|
||||
@(test -f $(GOLANGCI_LINT_PATH) && echo "github.com/golangci/golangci-lint is already installed. Skipping...") || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.56.1
|
||||
|
||||
.PHONY: install-oapi-codegen
|
||||
install-oapi-codegen:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.21 as builder
|
||||
FROM golang:1.22 as builder
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
FROM golang:1.21.6-alpine3.19 AS builder
|
||||
FROM golang:1.22.0-alpine3.19 AS builder
|
||||
|
||||
WORKDIR /twhelp
|
||||
|
||||
COPY ../../../../go.mod go.sum ./
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && apk --no-cache add make
|
||||
|
||||
COPY ../../../.. .
|
||||
COPY . .
|
||||
RUN make generate
|
||||
ARG CI_COMMIT_TAG="development"
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${CI_COMMIT_TAG##v}" -trimpath -o twhelp ./cmd/twhelp
|
||||
|
|
4
go.mod
4
go.mod
|
@ -1,13 +1,13 @@
|
|||
module gitea.dwysokinski.me/twhelp/corev3
|
||||
|
||||
go 1.21
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/ThreeDotsLabs/watermill v1.3.5
|
||||
github.com/ThreeDotsLabs/watermill-amqp/v2 v2.1.1
|
||||
github.com/brianvoe/gofakeit/v6 v6.28.0
|
||||
github.com/cenkalti/backoff/v4 v4.2.1
|
||||
github.com/elliotchance/phpserialize v1.3.3
|
||||
github.com/elliotchance/phpserialize v1.4.0
|
||||
github.com/ettle/strcase v0.2.0
|
||||
github.com/getkin/kin-openapi v0.123.0
|
||||
github.com/go-chi/chi/v5 v5.0.11
|
||||
|
|
4
go.sum
4
go.sum
|
@ -46,8 +46,8 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
|
|||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/elliotchance/phpserialize v1.3.3 h1:hV4QVmGdCiYgoBbw+ADt6fNgyZ2mYX0OgpnON1adTCM=
|
||||
github.com/elliotchance/phpserialize v1.3.3/go.mod h1:gt7XX9+ETUcLXbtTKEuyrqW3lcLUAeS/AnGZ2e49TZs=
|
||||
github.com/elliotchance/phpserialize v1.4.0 h1:cAp/9+KSnEbUC8oYCE32n2n84BeW8HOY3HMDI8hG2OY=
|
||||
github.com/elliotchance/phpserialize v1.4.0/go.mod h1:gt7XX9+ETUcLXbtTKEuyrqW3lcLUAeS/AnGZ2e49TZs=
|
||||
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
|
||||
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
|
|
|
@ -139,24 +139,22 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
return domain.NewListEnnoblementsParams()
|
||||
},
|
||||
assertEnnoblements: func(t *testing.T, params domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
assertEnnoblements: func(t *testing.T, _ domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(ennoblements))
|
||||
assert.True(t, slices.IsSortedFunc(ennoblements, func(a, b domain.Ennoblement) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := a.CreatedAt().Compare(b.CreatedAt()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.CreatedAt().Compare(b.CreatedAt()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -172,21 +170,21 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertEnnoblements: func(t *testing.T, params domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
assertEnnoblements: func(t *testing.T, _ domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(ennoblements))
|
||||
assert.True(t, slices.IsSortedFunc(ennoblements, func(a, b domain.Ennoblement) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return a.CreatedAt().Compare(b.CreatedAt()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.CreatedAt().Compare(b.CreatedAt()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -201,7 +199,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertEnnoblements: func(t *testing.T, params domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
assertEnnoblements: func(t *testing.T, _ domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(ennoblements))
|
||||
assert.True(t, slices.IsSortedFunc(ennoblements, func(a, b domain.Ennoblement) int {
|
||||
|
@ -212,7 +210,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -227,7 +225,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertEnnoblements: func(t *testing.T, params domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
assertEnnoblements: func(t *testing.T, _ domain.ListEnnoblementsParams, ennoblements domain.Ennoblements) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(ennoblements))
|
||||
assert.True(t, slices.IsSortedFunc(ennoblements, func(a, b domain.Ennoblement) int {
|
||||
|
@ -238,7 +236,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -264,7 +262,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -286,7 +284,7 @@ func testEnnoblementRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListEnnoblementsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListEnnoblementsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -142,26 +142,24 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
},
|
||||
assertPlayerSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListPlayerSnapshotsParams,
|
||||
_ domain.ListPlayerSnapshotsParams,
|
||||
playerSnapshots domain.PlayerSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(playerSnapshots))
|
||||
assert.True(t, slices.IsSortedFunc(playerSnapshots, func(a, b domain.PlayerSnapshot) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := a.Date().Compare(b.Date()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.Date().Compare(b.Date()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -179,23 +177,23 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
},
|
||||
assertPlayerSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListPlayerSnapshotsParams,
|
||||
_ domain.ListPlayerSnapshotsParams,
|
||||
playerSnapshots domain.PlayerSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(playerSnapshots))
|
||||
assert.True(t, slices.IsSortedFunc(playerSnapshots, func(a, b domain.PlayerSnapshot) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return a.Date().Compare(b.Date()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.Date().Compare(b.Date()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -212,7 +210,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
},
|
||||
assertPlayerSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListPlayerSnapshotsParams,
|
||||
_ domain.ListPlayerSnapshotsParams,
|
||||
playerSnapshots domain.PlayerSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
|
@ -225,7 +223,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -242,7 +240,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
},
|
||||
assertPlayerSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListPlayerSnapshotsParams,
|
||||
_ domain.ListPlayerSnapshotsParams,
|
||||
playerSnapshots domain.PlayerSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
|
@ -255,7 +253,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -285,7 +283,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -311,7 +309,7 @@ func testPlayerSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repo
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayerSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayerSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -123,21 +123,21 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
return domain.NewListPlayersParams()
|
||||
},
|
||||
assertPlayers: func(t *testing.T, params domain.ListPlayersParams, players domain.Players) {
|
||||
assertPlayers: func(t *testing.T, _ domain.ListPlayersParams, players domain.Players) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(players))
|
||||
assert.True(t, slices.IsSortedFunc(players, func(a, b domain.Player) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -150,21 +150,21 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
require.NoError(t, params.SetSort([]domain.PlayerSort{domain.PlayerSortServerKeyDESC, domain.PlayerSortIDDESC}))
|
||||
return params
|
||||
},
|
||||
assertPlayers: func(t *testing.T, params domain.ListPlayersParams, players domain.Players) {
|
||||
assertPlayers: func(t *testing.T, _ domain.ListPlayersParams, players domain.Players) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(players))
|
||||
assert.True(t, slices.IsSortedFunc(players, func(a, b domain.Player) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -193,7 +193,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -220,7 +220,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -236,7 +236,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertPlayers: func(t *testing.T, params domain.ListPlayersParams, players domain.Players) {
|
||||
assertPlayers: func(t *testing.T, _ domain.ListPlayersParams, players domain.Players) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, players)
|
||||
for _, s := range players {
|
||||
|
@ -247,7 +247,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -263,7 +263,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertPlayers: func(t *testing.T, params domain.ListPlayersParams, players domain.Players) {
|
||||
assertPlayers: func(t *testing.T, _ domain.ListPlayersParams, players domain.Players) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, players)
|
||||
for _, s := range players {
|
||||
|
@ -274,7 +274,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -296,7 +296,7 @@ func testPlayerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListPlayersParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListPlayersParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -122,7 +122,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
t.Helper()
|
||||
return domain.NewListServersParams()
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -143,7 +143,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
require.NoError(t, params.SetSort([]domain.ServerSort{domain.ServerSortOpenASC, domain.ServerSortKeyASC}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -172,7 +172,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
require.NoError(t, params.SetSort([]domain.ServerSort{domain.ServerSortOpenDESC, domain.ServerSortKeyDESC}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -270,7 +270,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -294,7 +294,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -318,7 +318,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
@ -342,7 +342,7 @@ func testServerRepository(t *testing.T, newRepos func(t *testing.T) repositories
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListServersParams, res domain.ListServersResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListServersParams, res domain.ListServersResult) {
|
||||
t.Helper()
|
||||
servers := res.Servers()
|
||||
assert.NotEmpty(t, len(servers))
|
||||
|
|
|
@ -156,24 +156,22 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
return domain.NewListTribeChangesParams()
|
||||
},
|
||||
assertTribeChanges: func(t *testing.T, params domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
assertTribeChanges: func(t *testing.T, _ domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeChanges))
|
||||
assert.True(t, slices.IsSortedFunc(tribeChanges, func(a, b domain.TribeChange) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := a.CreatedAt().Compare(b.CreatedAt()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.CreatedAt().Compare(b.CreatedAt()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -189,21 +187,21 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertTribeChanges: func(t *testing.T, params domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
assertTribeChanges: func(t *testing.T, _ domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeChanges))
|
||||
assert.True(t, slices.IsSortedFunc(tribeChanges, func(a, b domain.TribeChange) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return a.CreatedAt().Compare(b.CreatedAt()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.CreatedAt().Compare(b.CreatedAt()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -218,7 +216,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertTribeChanges: func(t *testing.T, params domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
assertTribeChanges: func(t *testing.T, _ domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeChanges))
|
||||
assert.True(t, slices.IsSortedFunc(tribeChanges, func(a, b domain.TribeChange) int {
|
||||
|
@ -229,7 +227,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -244,7 +242,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertTribeChanges: func(t *testing.T, params domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
assertTribeChanges: func(t *testing.T, _ domain.ListTribeChangesParams, tribeChanges domain.TribeChanges) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeChanges))
|
||||
assert.True(t, slices.IsSortedFunc(tribeChanges, func(a, b domain.TribeChange) int {
|
||||
|
@ -255,7 +253,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -281,7 +279,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -303,7 +301,7 @@ func testTribeChangeRepository(t *testing.T, newRepos func(t *testing.T) reposit
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeChangesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeChangesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -139,26 +139,24 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
},
|
||||
assertTribeSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListTribeSnapshotsParams,
|
||||
_ domain.ListTribeSnapshotsParams,
|
||||
tribeSnapshots domain.TribeSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeSnapshots))
|
||||
assert.True(t, slices.IsSortedFunc(tribeSnapshots, func(a, b domain.TribeSnapshot) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := a.Date().Compare(b.Date()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.Date().Compare(b.Date()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -176,23 +174,23 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
},
|
||||
assertTribeSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListTribeSnapshotsParams,
|
||||
_ domain.ListTribeSnapshotsParams,
|
||||
tribeSnapshots domain.TribeSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribeSnapshots))
|
||||
assert.True(t, slices.IsSortedFunc(tribeSnapshots, func(a, b domain.TribeSnapshot) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return a.Date().Compare(b.Date()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
a.Date().Compare(b.Date()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -209,7 +207,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
},
|
||||
assertTribeSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListTribeSnapshotsParams,
|
||||
_ domain.ListTribeSnapshotsParams,
|
||||
tribeSnapshots domain.TribeSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
|
@ -222,7 +220,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -239,7 +237,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
},
|
||||
assertTribeSnapshots: func(
|
||||
t *testing.T,
|
||||
params domain.ListTribeSnapshotsParams,
|
||||
_ domain.ListTribeSnapshotsParams,
|
||||
tribeSnapshots domain.TribeSnapshots,
|
||||
) {
|
||||
t.Helper()
|
||||
|
@ -252,7 +250,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -282,7 +280,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -308,7 +306,7 @@ func testTribeSnapshotRepository(t *testing.T, newRepos func(t *testing.T) repos
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribeSnapshotsParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribeSnapshotsParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -188,21 +188,21 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
return domain.NewListTribesParams()
|
||||
},
|
||||
assertTribes: func(t *testing.T, params domain.ListTribesParams, tribes domain.Tribes) {
|
||||
assertTribes: func(t *testing.T, _ domain.ListTribesParams, tribes domain.Tribes) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribes))
|
||||
assert.True(t, slices.IsSortedFunc(tribes, func(a, b domain.Tribe) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -215,21 +215,21 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
require.NoError(t, params.SetSort([]domain.TribeSort{domain.TribeSortServerKeyDESC, domain.TribeSortIDDESC}))
|
||||
return params
|
||||
},
|
||||
assertTribes: func(t *testing.T, params domain.ListTribesParams, tribes domain.Tribes) {
|
||||
assertTribes: func(t *testing.T, _ domain.ListTribesParams, tribes domain.Tribes) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(tribes))
|
||||
assert.True(t, slices.IsSortedFunc(tribes, func(a, b domain.Tribe) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -258,7 +258,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -285,7 +285,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -301,7 +301,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertTribes: func(t *testing.T, params domain.ListTribesParams, tribes domain.Tribes) {
|
||||
assertTribes: func(t *testing.T, _ domain.ListTribesParams, tribes domain.Tribes) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, tribes)
|
||||
for _, s := range tribes {
|
||||
|
@ -312,7 +312,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -328,7 +328,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
}))
|
||||
return params
|
||||
},
|
||||
assertTribes: func(t *testing.T, params domain.ListTribesParams, tribes domain.Tribes) {
|
||||
assertTribes: func(t *testing.T, _ domain.ListTribesParams, tribes domain.Tribes) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, tribes)
|
||||
for _, s := range tribes {
|
||||
|
@ -339,7 +339,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -361,7 +361,7 @@ func testTribeRepository(t *testing.T, newRepos func(t *testing.T) repositories)
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListTribesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListTribesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ func testVersionRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
t.Helper()
|
||||
return domain.NewListVersionsParams()
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListVersionsParams, res domain.ListVersionsResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListVersionsParams, res domain.ListVersionsResult) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, res.Versions())
|
||||
assert.True(t, slices.IsSortedFunc(res.Versions(), func(a, b domain.Version) int {
|
||||
|
@ -55,7 +55,7 @@ func testVersionRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
require.NoError(t, params.SetSort([]domain.VersionSort{domain.VersionSortCodeDESC}))
|
||||
return params
|
||||
},
|
||||
assertResult: func(t *testing.T, params domain.ListVersionsParams, res domain.ListVersionsResult) {
|
||||
assertResult: func(t *testing.T, _ domain.ListVersionsParams, res domain.ListVersionsResult) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, res.Versions())
|
||||
assert.True(t, slices.IsSortedFunc(res.Versions(), func(a, b domain.Version) int {
|
||||
|
|
|
@ -115,21 +115,21 @@ func testVillageRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
t.Helper()
|
||||
return domain.NewListVillagesParams()
|
||||
},
|
||||
assertVillages: func(t *testing.T, params domain.ListVillagesParams, villages domain.Villages) {
|
||||
assertVillages: func(t *testing.T, _ domain.ListVillagesParams, villages domain.Villages) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(villages))
|
||||
assert.True(t, slices.IsSortedFunc(villages, func(a, b domain.Village) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()); x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListVillagesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListVillagesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -142,21 +142,21 @@ func testVillageRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
require.NoError(t, params.SetSort([]domain.VillageSort{domain.VillageSortServerKeyDESC, domain.VillageSortIDDESC}))
|
||||
return params
|
||||
},
|
||||
assertVillages: func(t *testing.T, params domain.ListVillagesParams, villages domain.Villages) {
|
||||
assertVillages: func(t *testing.T, _ domain.ListVillagesParams, villages domain.Villages) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, len(villages))
|
||||
assert.True(t, slices.IsSortedFunc(villages, func(a, b domain.Village) int {
|
||||
if x := cmp.Compare(a.ServerKey(), b.ServerKey()) * -1; x != 0 {
|
||||
return x
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID()) * -1
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
) * -1
|
||||
}))
|
||||
},
|
||||
assertError: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListVillagesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListVillagesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -185,7 +185,7 @@ func testVillageRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListVillagesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListVillagesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -212,7 +212,7 @@ func testVillageRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListVillagesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListVillagesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
@ -234,7 +234,7 @@ func testVillageRepository(t *testing.T, newRepos func(t *testing.T) repositorie
|
|||
t.Helper()
|
||||
require.NoError(t, err)
|
||||
},
|
||||
assertTotal: func(t *testing.T, params domain.ListVillagesParams, total int) {
|
||||
assertTotal: func(t *testing.T, _ domain.ListVillagesParams, total int) {
|
||||
t.Helper()
|
||||
assert.NotEmpty(t, total)
|
||||
},
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestLogger(t *testing.T) {
|
|||
{
|
||||
name: "log level should be Info when status code >= 200 and < 400",
|
||||
register: func(r chi.Router) {
|
||||
r.Get("/info", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/info", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
},
|
||||
|
@ -46,7 +46,7 @@ func TestLogger(t *testing.T) {
|
|||
{
|
||||
name: "log level should be Warn when status code >= 400 and < 500",
|
||||
register: func(r chi.Router) {
|
||||
r.Get("/warn", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/warn", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
})
|
||||
},
|
||||
|
@ -62,7 +62,7 @@ func TestLogger(t *testing.T) {
|
|||
{
|
||||
name: "log level should be Error when status code >= 500",
|
||||
register: func(r chi.Router) {
|
||||
r.Get("/error", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/error", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
})
|
||||
},
|
||||
|
@ -83,7 +83,7 @@ func TestLogger(t *testing.T) {
|
|||
}),
|
||||
},
|
||||
register: func(r chi.Router) {
|
||||
r.Post("/x-forwarded-for", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Post("/x-forwarded-for", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
},
|
||||
|
@ -107,7 +107,7 @@ func TestLogger(t *testing.T) {
|
|||
}),
|
||||
},
|
||||
register: func(r chi.Router) {
|
||||
r.Get("/meta/test", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/meta/test", func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
},
|
||||
|
@ -150,7 +150,7 @@ func TestLogger(t *testing.T) {
|
|||
assert.Equal(t, req.Referer(), entry["httpRequest.referer"])
|
||||
assert.Equal(t, req.UserAgent(), entry["httpRequest.userAgent"])
|
||||
assert.Equal(t, req.Proto, entry["httpRequest.proto"])
|
||||
assert.Equal(t, float64(rr.Code), entry["httpResponse.status"])
|
||||
assert.InDelta(t, float64(rr.Code), entry["httpResponse.status"], 0.01)
|
||||
assert.GreaterOrEqual(t, entry["httpResponse.bytes"], 0.0)
|
||||
assert.GreaterOrEqual(t, entry["httpResponse.duration"], 0.0)
|
||||
if tt.assertEntry != nil {
|
||||
|
|
|
@ -277,10 +277,10 @@ func NewCreatePlayerParams(serverKey string, players BasePlayers, storedPlayers
|
|||
|
||||
var old Player
|
||||
idx, found := slices.BinarySearchFunc(storedPlayers, player, func(a Player, b BasePlayer) int {
|
||||
if res := cmp.Compare(a.ServerKey(), serverKey); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), serverKey),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
if found {
|
||||
old = storedPlayers[idx]
|
||||
|
|
|
@ -72,10 +72,10 @@ func TestPlayers_Delete(t *testing.T) {
|
|||
})
|
||||
|
||||
slices.SortFunc(players, func(a, b domain.Player) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
ids, tribeChangesParams, err := players.Delete(server.Key(), active)
|
||||
|
@ -152,10 +152,10 @@ func TestNewCreatePlayerParams(t *testing.T) {
|
|||
}
|
||||
storedPlayersSorted := slices.Clone(storedPlayers)
|
||||
slices.SortFunc(storedPlayersSorted, func(a, b domain.Player) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
expectedParams := []struct {
|
||||
|
|
|
@ -282,10 +282,10 @@ func NewCreateTribeParams(serverKey string, tribes BaseTribes, storedTribes Trib
|
|||
|
||||
var old Tribe
|
||||
idx, found := slices.BinarySearchFunc(storedTribes, t, func(a Tribe, b BaseTribe) int {
|
||||
if res := cmp.Compare(a.ServerKey(), serverKey); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), serverKey),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
if found {
|
||||
old = storedTribes[idx]
|
||||
|
|
|
@ -157,10 +157,10 @@ func NewCreateTribeChangeParamsFromPlayers(
|
|||
|
||||
var old Player
|
||||
idx, found := slices.BinarySearchFunc(storedPlayers, player, func(a Player, b BasePlayer) int {
|
||||
if res := cmp.Compare(a.ServerKey(), serverKey); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), serverKey),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
if found {
|
||||
old = storedPlayers[idx]
|
||||
|
|
|
@ -192,10 +192,10 @@ func TestNewCreateTribeChangeParamsFromPlayers(t *testing.T) {
|
|||
})
|
||||
|
||||
slices.SortFunc(storedPlayers, func(a, b domain.Player) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
res, err := domain.NewCreateTribeChangeParamsFromPlayers(server.Key(), players, storedPlayers)
|
||||
|
|
|
@ -55,10 +55,10 @@ func TestTribes_Delete(t *testing.T) {
|
|||
})
|
||||
|
||||
slices.SortFunc(tribes, func(a, b domain.Tribe) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
assert.Equal(t, expectedIDs, tribes.Delete(server.Key(), active))
|
||||
|
@ -151,10 +151,10 @@ func TestNewCreateTribeParams(t *testing.T) {
|
|||
})
|
||||
|
||||
slices.SortFunc(storedTribes, func(a, b domain.Tribe) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
res, err := domain.NewCreateTribeParams(server.Key(), tribes, storedTribes)
|
||||
|
|
|
@ -50,10 +50,10 @@ func TestVillages_Delete(t *testing.T) {
|
|||
})
|
||||
|
||||
slices.SortFunc(villages, func(a, b domain.Village) int {
|
||||
if res := cmp.Compare(a.ServerKey(), b.ServerKey()); res != 0 {
|
||||
return res
|
||||
}
|
||||
return cmp.Compare(a.ID(), b.ID())
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.ServerKey(), b.ServerKey()),
|
||||
cmp.Compare(a.ID(), b.ID()),
|
||||
)
|
||||
})
|
||||
|
||||
assert.Equal(t, expectedIDs, villages.Delete(server.Key(), active))
|
||||
|
|
|
@ -330,7 +330,7 @@ func TestDataSync(t *testing.T) {
|
|||
assert.EqualValues(collect, expected["RankTotal"], actual.OD().RankTotal(), msg)
|
||||
assert.EqualValues(collect, expected["ScoreTotal"], actual.OD().ScoreTotal(), msg)
|
||||
assert.Equal(collect, expected["ProfileURL"], actual.ProfileURL().String(), msg)
|
||||
assert.EqualValues(collect, expected["Dominance"], actual.Dominance(), msg)
|
||||
assert.InDelta(collect, expected["Dominance"], actual.Dominance(), 0.01, msg)
|
||||
assert.EqualValues(collect, expected["BestRank"], actual.BestRank(), msg)
|
||||
assert.NotEmpty(collect, actual.BestRankAt(), msg)
|
||||
assert.EqualValues(collect, expected["MostPoints"], actual.MostPoints(), msg)
|
||||
|
|
|
@ -25,6 +25,11 @@ const routerCloseTimeout = 10 * time.Second
|
|||
func RunRouterWithContext(tb TestingTB, ctx context.Context, rs ...Registerer) *message.Router {
|
||||
tb.Helper()
|
||||
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
tb.Cleanup(func() {
|
||||
cancel(nil)
|
||||
})
|
||||
|
||||
router, err := message.NewRouter(message.RouterConfig{CloseTimeout: routerCloseTimeout}, watermill.NopLogger{})
|
||||
require.NoError(tb, err)
|
||||
tb.Cleanup(func() {
|
||||
|
@ -36,9 +41,16 @@ func RunRouterWithContext(tb TestingTB, ctx context.Context, rs ...Registerer) *
|
|||
}
|
||||
|
||||
go func() {
|
||||
require.NoError(tb, router.Run(ctx))
|
||||
if runErr := router.Run(ctx); runErr != nil {
|
||||
cancel(runErr)
|
||||
}
|
||||
}()
|
||||
<-router.Running()
|
||||
|
||||
select {
|
||||
case <-router.Running():
|
||||
case <-ctx.Done():
|
||||
require.NoError(tb, context.Cause(ctx))
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue