♻️ Simplify error usage in user package

This commit is contained in:
Maxim Lebedev 2022-01-30 01:46:43 +05:00
parent 2e30613089
commit f62ce1db0a
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
3 changed files with 9 additions and 12 deletions

View File

@ -2,7 +2,6 @@ package user
import (
"context"
"errors"
"source.toby3d.me/website/indieauth/internal/domain"
)
@ -11,4 +10,4 @@ type Repository interface {
Get(ctx context.Context, me *domain.Me) (*domain.User, error)
}
var ErrNotExist = errors.New("user not exists")
var ErrNotExist error = domain.NewError(domain.ErrorCodeServerError, "user not exist", "")

View File

@ -15,22 +15,20 @@ type httpUserRepository struct {
client *http.Client
}
const DefaultMaxRedirectsCount int = 10
const (
DefaultMaxRedirectsCount int = 10
hCard string = "h-card"
propertyEmail string = "email"
propertyName string = "name"
propertyPhoto string = "photo"
propertyURL string = "url"
relAuthorizationEndpoint string = "authorization_endpoint"
relIndieAuthMetadata string = "indieauth-metadata"
relMicropub string = "micropub"
relMicrosub string = "microsub"
relTicketEndpoint string = "ticket_endpoint"
relTokenEndpoint string = "token_endpoint"
hCard string = "h-card"
propertyEmail string = "email"
propertyName string = "name"
propertyPhoto string = "photo"
propertyURL string = "url"
)
func NewHTTPUserRepository(client *http.Client) user.Repository {

View File

@ -16,7 +16,7 @@ import (
func TestFetch(t *testing.T) {
t.Parallel()
me := domain.TestMe(t)
me := domain.TestMe(t, "https://user.example.net")
user := domain.TestUser(t)
store := new(sync.Map)