♻️ Use TestURL in other test domains
This commit is contained in:
parent
c9a76ddbd6
commit
bf7be3c4fa
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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/")},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue