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