mirror of
https://github.com/jlelse/GoBlog
synced 2024-06-29 12:07:36 +00:00
33 lines
658 B
Go
33 lines
658 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ap "github.com/go-ap/activitypub"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_apUsername(t *testing.T) {
|
|
item, err := ap.UnmarshalJSON([]byte(`
|
|
{
|
|
"@context": [
|
|
"https://www.w3.org/ns/activitystreams",
|
|
"https://w3id.org/security/v1"
|
|
],
|
|
"id": "https://example.org/users/user",
|
|
"type": "Person",
|
|
"preferredUsername": "user",
|
|
"name": "Example user",
|
|
"url": "https://example.org/@user"
|
|
}
|
|
`))
|
|
require.NoError(t, err)
|
|
|
|
actor, err := ap.ToActor(item)
|
|
require.NoError(t, err)
|
|
|
|
username := apUsername(actor)
|
|
assert.Equal(t, "@user@example.org", username)
|
|
}
|