this repo has no description
0
fork

Configure Feed

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

testing: PDS+fakedata internal integration test

+106
+106
testing/pds_fakedata_test.go
··· 1 + package testing 2 + 3 + import ( 4 + "testing" 5 + "time" 6 + 7 + "github.com/bluesky-social/indigo/fakedata" 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:5159" 16 + adminPassword = "admin" 17 + celebCount = 2 18 + regularCount = 5 19 + maxPosts = 5 20 + maxFollows = 5 21 + // TODO: golang PDS does not support putRecord 22 + maxMutes = 0 // 2 23 + fracMention = 0.3 24 + // TODO: golang PDS does not support images 25 + genAvatar = false // true 26 + genBanner = false // true 27 + fracImage = 0.0 // 0.3 28 + ) 29 + 30 + func genTestCatalog(t *testing.T, pdsHost string) fakedata.AccountCatalog { 31 + 32 + ap := adminPassword 33 + xrpccAdmin := xrpc.Client{ 34 + Client: util.TestingHTTPClient(), 35 + Host: pdsHost, 36 + } 37 + xrpccAdmin.AdminToken = &ap 38 + 39 + var catalog fakedata.AccountCatalog 40 + for i := 0; i < celebCount; i++ { 41 + usr, err := fakedata.GenAccount(&xrpccAdmin, i, "celebrity") 42 + if err != nil { 43 + t.Fatal(err) 44 + } 45 + catalog.Celebs = append(catalog.Celebs, *usr) 46 + } 47 + for i := 0; i < regularCount; i++ { 48 + usr, err := fakedata.GenAccount(&xrpccAdmin, i, "regular") 49 + if err != nil { 50 + t.Fatal(err) 51 + } 52 + catalog.Regulars = append(catalog.Regulars, *usr) 53 + } 54 + return catalog 55 + } 56 + 57 + func TestPDSFakedata(t *testing.T) { 58 + if testing.Short() { 59 + t.Skip("skipping PDS+fakedata test in 'short' test mode") 60 + } 61 + assert := assert.New(t) 62 + plcc := testPLC(t) 63 + pds := mustSetupPDS(t, "localhost:5159", ".test", plcc) 64 + pds.Run(t) 65 + 66 + time.Sleep(time.Millisecond * 50) 67 + 68 + catalog := genTestCatalog(t, pdsHost) 69 + combined := catalog.Combined() 70 + testClient := util.TestingHTTPClient() 71 + 72 + // generate profile, graph, posts 73 + for _, acc := range combined { 74 + xrpcc, err := fakedata.AccountXrpcClient(pdsHost, &acc) 75 + xrpcc.Client = testClient 76 + if err != nil { 77 + t.Fatal(err) 78 + } 79 + // TODO: golang PDS does not support putRecord 80 + //assert.NoError(fakedata.GenProfile(xrpcc, &acc, genAvatar, genBanner)) 81 + assert.NoError(fakedata.GenFollowsAndMutes(xrpcc, &catalog, &acc, maxFollows, maxMutes)) 82 + assert.NoError(fakedata.GenPosts(xrpcc, &catalog, &acc, maxPosts, fracImage, fracMention)) 83 + } 84 + 85 + // generate interactions (additional posts, etc) 86 + for _, acc := range combined { 87 + xrpcc, err := fakedata.AccountXrpcClient(pdsHost, &acc) 88 + xrpcc.Client = testClient 89 + if err != nil { 90 + t.Fatal(err) 91 + } 92 + assert.NoError(fakedata.GenFollowsAndMutes(xrpcc, &catalog, &acc, maxFollows, maxMutes)) 93 + assert.NoError(fakedata.GenPosts(xrpcc, &catalog, &acc, maxPosts, fracImage, fracMention)) 94 + } 95 + 96 + // do browsing (read-only) 97 + for _, acc := range combined { 98 + xrpcc, err := fakedata.AccountXrpcClient(pdsHost, &acc) 99 + xrpcc.Client = testClient 100 + if err != nil { 101 + t.Fatal(err) 102 + } 103 + // TODO: golang listNotifications broken 104 + //assert.NoError(fakedata.BrowseAccount(xrpcc, &acc)) 105 + } 106 + }