Dawid Wysokiński
e468a1f391
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: twhelp/core#71
51 lines
917 B
Go
51 lines
917 B
Go
package domain_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dwysokinski.me/twhelp/core/internal/domain"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNewEnnoblementSortBy(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("OK", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
s string
|
|
output domain.EnnoblementSortBy
|
|
}{
|
|
{
|
|
s: "id",
|
|
output: domain.EnnoblementSortByID,
|
|
},
|
|
{
|
|
s: "createdAt",
|
|
output: domain.EnnoblementSortByCreatedAt,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
tt := tt
|
|
|
|
t.Run(tt.s, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
res, err := domain.NewEnnoblementSortBy(tt.s)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, tt.output, res)
|
|
})
|
|
}
|
|
})
|
|
|
|
t.Run("ERR: unsupported sort by", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
res, err := domain.NewEnnoblementSortBy("unsupported")
|
|
assert.ErrorIs(t, err, domain.ErrUnsupportedSortBy)
|
|
assert.Zero(t, res)
|
|
})
|
|
}
|