-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: In r/demo/boards, add tests for CreateRepost and related errors
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
- Loading branch information
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// PKGPATH: gno.land/r/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/p/demo/testutils" | ||
"gno.land/r/demo/boards" | ||
"gno.land/r/demo/users" | ||
) | ||
|
||
func main() { | ||
users.Register("", "gnouser", "my profile") | ||
// create a post via registered user | ||
bid1 := boards.CreateBoard("test_board1") | ||
pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") | ||
bid2 := boards.CreateBoard("test_board2") | ||
|
||
// create a repost via anon user | ||
test2 := testutils.TestAddress("test2") | ||
std.TestSetOrigCaller(test2) | ||
std.TestSetOrigSend(std.Coins{{"ugnot", 9000000}}, nil) | ||
|
||
rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2) | ||
println(rid) | ||
println(boards.Render("test_board1")) | ||
} | ||
|
||
// Error: | ||
// please register, otherwise minimum fee 100000000 is required if anonymous |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// PKGPATH: gno.land/r/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
"gno.land/r/demo/users" | ||
) | ||
|
||
func main() { | ||
users.Register("", "gnouser", "my profile") | ||
bid1 := boards.CreateBoard("test_board1") | ||
pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") | ||
bid2 := boards.CreateBoard("test_board2") | ||
|
||
// create a repost to a non-existing board | ||
rid := boards.CreateRepost(5, pid, "", "Check this out", bid2) | ||
println(rid) | ||
println(boards.Render("test_board1")) | ||
} | ||
|
||
// Error: | ||
// src board not exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// PKGPATH: gno.land/r/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
"gno.land/r/demo/users" | ||
) | ||
|
||
func main() { | ||
users.Register("", "gnouser", "my profile") | ||
bid1 := boards.CreateBoard("test_board1") | ||
boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") | ||
bid2 := boards.CreateBoard("test_board2") | ||
|
||
// create a repost to a non-existing thread | ||
rid := boards.CreateRepost(bid1, 5, "", "Check this out", bid2) | ||
println(rid) | ||
println(boards.Render("test_board1")) | ||
} | ||
|
||
// Error: | ||
// thread not exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// PKGPATH: gno.land/r/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
"gno.land/r/demo/users" | ||
) | ||
|
||
func main() { | ||
users.Register("", "gnouser", "my profile") | ||
bid1 := boards.CreateBoard("test_board1") | ||
pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") | ||
boards.CreateBoard("test_board2") | ||
|
||
// create a repost to a non-existing destination board | ||
rid := boards.CreateRepost(bid1, pid, "", "Check this out", 5) | ||
println(rid) | ||
println(boards.Render("test_board1")) | ||
} | ||
|
||
// Error: | ||
// dst board not exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// PKGPATH: gno.land/r/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
"gno.land/r/demo/users" | ||
) | ||
|
||
var ( | ||
bid1 boards.BoardID | ||
bid2 boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
users.Register("", "gnouser", "my profile") | ||
|
||
bid1 = boards.CreateBoard("test_board1") | ||
pid = boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") | ||
bid2 = boards.CreateBoard("test_board2") | ||
} | ||
|
||
func main() { | ||
rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2) | ||
println(rid) | ||
println(boards.Render("test_board1")) | ||
} | ||
|
||
// Output: | ||
// 1 | ||
// \[[post](/r/demo/boards?help&__func=CreateThread&bid=1&body.type=textarea)] | ||
// | ||
// ---------------------------------------- | ||
// ## [First Post (title)](/r/demo/boards:test_board1/1) | ||
// | ||
// Body of the first post. (body) | ||
// \- [@gnouser](/r/demo/users:gnouser), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board1/1) \[[x](/r/demo/boards?help&__func=DeletePost&bid=1&threadid=1&postid=1)] (0 replies) (1 reposts) |