z_hub_3_b_filetest.gno
0.87 Kb · 38 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_hub_3_b_filetest
2
3// Test getting threads from a board
4package z_hub_3_b_filetest
5
6import (
7 "testing"
8
9 boards2 "gno.land/r/gnoland/boards2/v1"
10)
11
12var board boards2.Board
13
14func init(cur realm) {
15 testing.SetRealm(testing.NewUserRealm("g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"))
16 boardID := boards2.CreateBoard(cross(cur), "test123", false, false)
17
18 // Create a couple of board threads
19 boards2.CreateThread(cross(cur), boardID, "First", "Body")
20 boards2.CreateThread(cross(cur), boardID, "Second", "Body")
21 boards2.CreateThread(cross(cur), boardID, "Third", "Body")
22
23 // Get readonly board
24 board, _ = boards2.GetBoard(uint64(boardID))
25}
26
27func main(cur realm) {
28 threads := boards2.GetThreads(board.ID(), 0, board.ThreadCount())
29
30 for _, t := range threads {
31 println(t.ID(), t.Title())
32 }
33}
34
35// Output:
36// 1 First
37// 2 Second
38// 3 Third