This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
core-old/internal/domain/village_test.go
Dawid Wysokiński c545ebd7d7
All checks were successful
continuous-integration/drone/push Build is passing
refactor: rename domain.UserError -> domain.Error
2022-12-31 11:00:30 +01:00

54 lines
1.0 KiB
Go

package domain_test
import (
"testing"
"gitea.dwysokinski.me/twhelp/core/internal/domain"
"github.com/stretchr/testify/assert"
)
func TestVillage_FullName(t *testing.T) {
t.Parallel()
v := domain.Village{
ID: 1234,
Name: "Village",
X: 450,
Y: 450,
Continent: "K44",
}
assert.Equal(t, "Village (450|450) K44", v.FullName())
}
func TestVillageMeta_FullName(t *testing.T) {
t.Parallel()
v := domain.Village{
ID: 1234,
Name: "Village",
X: 450,
Y: 450,
Continent: "K44",
}
meta := domain.VillageMeta{
ID: v.ID,
Name: v.Name,
X: v.X,
Y: v.Y,
Continent: v.Continent,
}
assert.Equal(t, v.FullName(), meta.FullName())
}
func TestVillageNotFoundError(t *testing.T) {
t.Parallel()
err := domain.VillageNotFoundError{
ID: 1234,
}
var _ domain.Error = err
assert.Equal(t, "village (id=1234) not found", err.Error())
assert.Equal(t, err.Error(), err.UserError())
assert.Equal(t, domain.ErrorCodeEntityNotFound, err.Code())
}