MCPcopy Create free account
hub / github.com/davecheney/pub / MockActor

Function MockActor

models/models_test.go:24–44  ·  view source on GitHub ↗

MockActor creates a new actor in the database.

(t *testing.T, tx *gorm.DB, name, domain string, opts ...func(*Actor))

Source from the content-addressed store, hash-verified

22// MockActor creates a new actor in the database.
23func MockActor(t *testing.T, tx *gorm.DB, name, domain string, opts ...func(*Actor)) *Actor {
24 t.Helper()
25 require := require.New(t)
26
27 kp, err := crypto.GenerateRSAKeypair()
28 require.NoError(err)
29
30 actor := &Actor{
31 ID: snowflake.Now(),
32 URI: fmt.Sprintf("https://%s/%s", domain, name),
33 Name: name,
34 Domain: domain,
35 DisplayName: name,
36 Avatar: "https://avatars.githubusercontent.com/u/1024?v=4",
37 Header: "https://avatars.githubusercontent.com/u/1024?v=4",
38 PublicKey: kp.PublicKey,
39 }
40 for _, opt := range opts {
41 opt(actor)
42 }
43 require.NoError(tx.Create(actor).Error)
44 return actor
45}
46
47func MockStatus(t *testing.T, tx *gorm.DB, actor *Actor, note string) *Status {

Callers 3

TestRelationshipsFunction · 0.85
TestReactionsFunction · 0.85
TestActorsFunction · 0.85

Calls 2

GenerateRSAKeypairFunction · 0.92
CreateMethod · 0.45

Tested by

no test coverage detected