this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fakedata: localinterop test (for typescript PDS)

+91
+91
fakedata/localinterop_test.go
··· 1 + //go:build localinterop 2 + 3 + package fakedata 4 + 5 + import ( 6 + "testing" 7 + 8 + "github.com/bluesky-social/indigo/util" 9 + "github.com/bluesky-social/indigo/xrpc" 10 + 11 + "github.com/stretchr/testify/assert" 12 + ) 13 + 14 + const ( 15 + pdsHost = "http://localhost:2583" 16 + adminPassword = "admin" 17 + celebCount = 2 18 + regularCount = 5 19 + maxPosts = 5 20 + maxFollows = 5 21 + maxMutes = 2 22 + fracImage = 0.3 23 + fracMention = 0.3 24 + ) 25 + 26 + func genTestCatalog(t *testing.T, pdsHost string) AccountCatalog { 27 + 28 + ap := adminPassword 29 + xrpccAdmin := xrpc.Client{ 30 + Client: util.TestingHTTPClient(), 31 + Host: pdsHost, 32 + } 33 + xrpccAdmin.AdminToken = &ap 34 + 35 + var catalog AccountCatalog 36 + for i := 0; i < celebCount; i++ { 37 + usr, err := GenAccount(&xrpccAdmin, i, "celebrity") 38 + if err != nil { 39 + t.Fatal(err) 40 + } 41 + catalog.Celebs = append(catalog.Celebs, *usr) 42 + } 43 + for i := 0; i < regularCount; i++ { 44 + usr, err := GenAccount(&xrpccAdmin, i, "regular") 45 + if err != nil { 46 + t.Fatal(err) 47 + } 48 + catalog.Regulars = append(catalog.Regulars, *usr) 49 + } 50 + return catalog 51 + } 52 + 53 + // runs basic fakedata generation against a local PDS process. eg, the 54 + // typescript implementation, running locally or in docker 55 + func TestFakedataLocalInterop(t *testing.T) { 56 + assert := assert.New(t) 57 + _ = assert 58 + 59 + catalog := genTestCatalog(t, pdsHost) 60 + combined := catalog.Combined() 61 + 62 + // generate profile, graph, posts 63 + for _, acc := range combined { 64 + xrpcc, err := AccountXrpcClient(pdsHost, &acc) 65 + if err != nil { 66 + t.Fatal(err) 67 + } 68 + assert.NoError(GenProfile(xrpcc, &acc, true, true)) 69 + assert.NoError(GenFollowsAndMutes(xrpcc, &catalog, &acc, maxFollows, maxMutes)) 70 + assert.NoError(GenPosts(xrpcc, &catalog, &acc, maxPosts, fracImage, fracMention)) 71 + } 72 + 73 + // generate interactions (additional posts, etc) 74 + for _, acc := range combined { 75 + xrpcc, err := AccountXrpcClient(pdsHost, &acc) 76 + if err != nil { 77 + t.Fatal(err) 78 + } 79 + assert.NoError(GenFollowsAndMutes(xrpcc, &catalog, &acc, maxFollows, maxMutes)) 80 + assert.NoError(GenPosts(xrpcc, &catalog, &acc, maxPosts, fracImage, fracMention)) 81 + } 82 + 83 + // do browsing (read-only) 84 + for _, acc := range combined { 85 + xrpcc, err := AccountXrpcClient(pdsHost, &acc) 86 + if err != nil { 87 + t.Fatal(err) 88 + } 89 + assert.NoError(BrowseAccount(xrpcc, &acc)) 90 + } 91 + }