From bf7be3c4fa9ec665dfd28b872fa27b704ca8b84f Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Wed, 5 Jan 2022 14:55:48 +0500 Subject: [PATCH] :recycle: Use TestURL in other test domains --- internal/domain/client.go | 18 +++--------------- internal/domain/profile.go | 12 ++---------- internal/domain/ticket.go | 12 ++---------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/internal/domain/client.go b/internal/domain/client.go index a28693a..5e72d20 100644 --- a/internal/domain/client.go +++ b/internal/domain/client.go @@ -2,8 +2,6 @@ package domain import ( "testing" - - "github.com/stretchr/testify/require" ) // Client describes the client requesting data about the user. @@ -19,29 +17,19 @@ type Client struct { func TestClient(tb testing.TB) *Client { tb.Helper() - url, err := NewURL("https://app.example.com/") - require.NoError(tb, err) - - logo, err := NewURL("https://app.example.com/logo.png") - require.NoError(tb, err) - redirects := make([]*URL, 0) - for _, redirect := range []string{ "https://app.example.net/redirect", "https://app.example.com/redirect", } { - u, err := NewURL(redirect) - require.NoError(tb, err) - - redirects = append(redirects, u) + redirects = append(redirects, TestURL(tb, redirect)) } return &Client{ ID: TestClientID(tb), Name: []string{"Example App"}, - URL: []*URL{url}, - Logo: []*URL{logo}, + URL: []*URL{TestURL(tb, "https://app.example.com/")}, + Logo: []*URL{TestURL(tb, "https://app.example.com/logo.png")}, RedirectURI: redirects, } } diff --git a/internal/domain/profile.go b/internal/domain/profile.go index a2bc396..6523a85 100644 --- a/internal/domain/profile.go +++ b/internal/domain/profile.go @@ -2,8 +2,6 @@ package domain import ( "testing" - - "github.com/stretchr/testify/require" ) // Profile describes the data about the user. @@ -28,16 +26,10 @@ func NewProfile() *Profile { func TestProfile(tb testing.TB) *Profile { tb.Helper() - photo, err := NewURL("https://user.example.net/photo.jpg") - require.NoError(tb, err) - - url, err := NewURL("https://user.example.net/") - require.NoError(tb, err) - return &Profile{ Email: []Email{"user@example.net"}, Name: []string{"Example User"}, - Photo: []*URL{photo}, - URL: []*URL{url}, + Photo: []*URL{TestURL(tb, "https://user.example.net/photo.jpg")}, + URL: []*URL{TestURL(tb, "https://user.example.net/")}, } } diff --git a/internal/domain/ticket.go b/internal/domain/ticket.go index 35f5477..69043bc 100644 --- a/internal/domain/ticket.go +++ b/internal/domain/ticket.go @@ -2,8 +2,6 @@ package domain import ( "testing" - - "github.com/stretchr/testify/require" ) type Ticket struct { @@ -20,15 +18,9 @@ type Ticket struct { func TestTicket(tb testing.TB) *Ticket { tb.Helper() - subject, err := NewMe("https://bob.example.org/") - require.NoError(tb, err) - - resource, err := NewURL("https://alice.example.com/private/") - require.NoError(tb, err) - return &Ticket{ + Resource: TestURL(tb, "https://alice.example.com/private/"), + Subject: TestMe(tb), Ticket: "32985723984723985792834", - Resource: resource, - Subject: subject, } }