Dawid Wysokiński
1c8694f68e
All checks were successful
continuous-integration/drone/push Build is passing
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package adapter_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/adapter"
|
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/domain"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestVillageRedisRepository_SaveTranslateCoordsParams_GetTranslateCoordsParams(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if testing.Short() {
|
|
t.Skip("skipping long-running test")
|
|
}
|
|
|
|
repo := adapter.NewVillageRedisRepository(newRedisClient(t))
|
|
|
|
params, err := domain.NewTranslateVillageCoordsParams("pl", "pl181", "123|123 898|123", 20)
|
|
require.NoError(t, err)
|
|
|
|
assert.NoError(t, repo.SaveTranslateCoordsParams(context.Background(), params))
|
|
|
|
paramsRedis, err := repo.GetTranslateCoordsParams(context.Background(), params.SHA256())
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, params, paramsRedis)
|
|
|
|
sha256Hash := params.SHA256() + "123"
|
|
paramsRedis, err = repo.GetTranslateCoordsParams(context.Background(), sha256Hash)
|
|
assert.ErrorIs(t, err, domain.TranslateVillageCoordsParamsNotFoundError{
|
|
SHA256: sha256Hash,
|
|
})
|
|
assert.Zero(t, paramsRedis)
|
|
}
|