Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_31_a_filetest.gno

1.67 Kb · 58 lines
 1// Open board: Test creating a new thread as a non member user
 2package main
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"chain"
 8	"testing"
 9
10	"gno.land/p/gnoland/boards"
11
12	boards2 "gno.land/r/gnoland/boards2/v1"
13	users "gno.land/r/gnoland/users/v1"
14)
15
16const (
17	owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
18	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
19	title         = "Test Thread"
20	body          = "Test body"
21)
22
23var bid boards.ID // Operate on board DAO
24
25func init() {
26	testing.SetRealm(testing.NewUserRealm(owner))
27	bid = boards2.CreateBoard(cross, "test123", false, true)
28
29	// Register a username which is required to be able to add a reply
30	testing.SetRealm(testing.NewUserRealm(user))
31	users.Register(cross, "user123")
32
33	// Make sure user account has the required amount of GNOT for open board actions
34	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
35}
36
37func main() {
38	testing.SetRealm(testing.NewUserRealm(user))
39
40	// Non members should be able to create threads
41	tid := boards2.CreateThread(cross, bid, title, body)
42
43	// Ensure that returned ID is right
44	println(tid == 1)
45
46	// Render content must contains thread's title and body
47	println(boards2.Render("test123/1"))
48}
49
50// Output:
51// true
52// # [Boards](/r/gnoland/boards2/v1) › [test123](/r/gnoland/boards2/v1:test123)
53// ## Test Thread
54//
55// **[@user123](/u/user123)** · 2009-02-13 11:31pm UTC
56// Test body
57//
58// ↳ [Flag](/r/gnoland/boards2/v1:test123/1/flag) • [Repost](/r/gnoland/boards2/v1:test123/1/repost) • [Comment](/r/gnoland/boards2/v1:test123/1/reply) • [Edit](/r/gnoland/boards2/v1:test123/1/edit) • [Delete](/r/gnoland/boards2/v1$help&func=DeleteThread&boardID=1&threadID=1)