Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_create_thread_05_filetest.gno

1.55 Kb · 53 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)
14
15const (
16	owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
17	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
18	title         = "Test Thread"
19	body          = "Test body"
20)
21
22var bid boards.ID // Operate on board DAO
23
24func init() {
25	testing.SetRealm(testing.NewUserRealm(owner))
26	bid = boards2.CreateBoard(cross, "test123", false, true)
27
28	// Make sure user account has the required amount of GNOT for open board actions
29	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
30}
31
32func main() {
33	testing.SetRealm(testing.NewUserRealm(user))
34
35	// Non members should be able to create threads
36	tid := boards2.CreateThread(cross, bid, title, body)
37
38	// Ensure that returned ID is right
39	println(tid == 1)
40
41	// Render content must contains thread's title and body
42	println(boards2.Render("test123/1"))
43}
44
45// Output:
46// true
47// # [Boards](/r/gnoland/boards2/v1) › [test123](/r/gnoland/boards2/v1:test123)
48// ## Test Thread
49//
50// **[g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj](/u/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj)** · 2009-02-13 11:31pm UTC
51// Test body
52//
53// ↳ [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)