this repo has no description
0
fork

Configure Feed

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

expand feedpost test to cover JSON output

+39 -5
+39 -5
testing/feedpost_test.go
··· 81 81 82 82 fmt.Printf("OUTPUT: %x\n", outCborBytes.Bytes()) 83 83 84 - // marshal as JSON 84 + // marshal as JSON, compare against expected 85 + expectedJson := `{ 86 + "$type": "app.bsky.feed.post", 87 + "createdAt": "2023-03-29T20:59:19.417Z", 88 + "embed": { 89 + "$type": "app.bsky.embed.recordWithMedia", 90 + "media": { 91 + "$type": "app.bsky.embed.images", 92 + "images": [ 93 + { 94 + "alt": "", 95 + "image": { 96 + "$type": "blob", 97 + "ref": { 98 + "$link": "bafkreieqq463374bbcbeq7gpmet5rvrpeqow6t4rtjzrkhnlumdylagaqa" 99 + }, 100 + "mimeType": "image/jpeg", 101 + "size": 751473 102 + } 103 + } 104 + ] 105 + }, 106 + "record": { 107 + "$type": "app.bsky.embed.record", 108 + "record": { 109 + "cid": "bafyreiaku7udekkiijxcuue3sn6esz7qijqj637rigz4xqdw57fk5houji", 110 + "uri": "at://did:plc:rbtury4cp2sdk4tvnedaqu54/app.bsky.feed.post/3jilislho4s2k" 111 + } 112 + } 113 + }, 114 + "text": "Who the hell do you think you are" 115 + }` 116 + 85 117 outJsonBytes, err := json.Marshal(fp) 86 118 assert.NoError(err) 87 - var outJson map[string]interface{} 88 - assert.NoError(json.Unmarshal(outJsonBytes, &outJson)) 89 - assert.Equal("app.bsky.feed.post", outJson["$type"]) 90 - // TODO: more 119 + fmt.Println(string(outJsonBytes)) 120 + var outJsonObj map[string]interface{} 121 + assert.NoError(json.Unmarshal(outJsonBytes, &outJsonObj)) 122 + var expectedJsonObj map[string]interface{} 123 + assert.NoError(json.Unmarshal([]byte(expectedJson), &expectedJsonObj)) 124 + assert.Equal(expectedJsonObj, outJsonObj) 91 125 }