z_ui_thread_06_filetest.gno
1.59 Kb · 50 lines
1// Render thread repost of a flagged thread.
2package main
3
4import (
5 "testing"
6
7 "gno.land/p/gnoland/boards"
8
9 boards2 "gno.land/r/gnoland/boards2/v1"
10)
11
12const (
13 owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
14 srcBoardName = "test-board"
15 dstBoardName = "test-board-2"
16)
17
18var repostThreadID boards.ID
19
20func init() {
21 testing.SetRealm(testing.NewUserRealm(owner))
22
23 // Create a board and a thread
24 boardID := boards2.CreateBoard(cross, srcBoardName, false, false)
25 threadID := boards2.CreateThread(cross, boardID, "Foo", "Body")
26
27 // Repost thread into a different board
28 dstBoardID := boards2.CreateBoard(cross, dstBoardName, false, false)
29 repostThreadID = boards2.CreateRepost(cross, boardID, threadID, dstBoardID, "Bar", "Body2")
30
31 // Flag original thread
32 boards2.SetFlaggingThreshold(cross, boardID, 1)
33 boards2.FlagThread(cross, boardID, threadID, "Reason")
34}
35
36func main() {
37 path := dstBoardName + "/" + repostThreadID.String()
38 println(boards2.Render(path))
39}
40
41// Output:
42// # [Boards](/r/gnoland/boards2/v1) › [test\-board\-2](/r/gnoland/boards2/v1:test-board-2)
43// ## Bar
44//
45// **[g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq](/u/g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq)** `owner` · 2009-02-13 11:31pm UTC
46// Body2
47//
48// > ⚠ Source post has been flagged as inappropriate
49//
50// ↳ [Flag](/r/gnoland/boards2/v1:test-board-2/1/flag) • [Repost](/r/gnoland/boards2/v1:test-board-2/1/repost) • [Comment](/r/gnoland/boards2/v1:test-board-2/1/reply) • [Edit](/r/gnoland/boards2/v1:test-board-2/1/edit) • [Delete](/r/gnoland/boards2/v1$help&func=DeleteThread&boardID=2&threadID=1)