-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return board filetests, make them work
- Loading branch information
Showing
34 changed files
with
2,098 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
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,22 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
) | ||
|
||
var bid boards.BoardID | ||
|
||
func init() { | ||
bid = boards.CreateBoard("test_board") | ||
boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") | ||
pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") | ||
boards.CreateReply(bid, pid, pid, "Reply of the second post") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board")) | ||
} | ||
|
||
// Error: | ||
// expected package name [boards_test] but got [boards] |
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,27 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var bid boards.BoardID | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
boards.CreateThread(1, "First Post (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board")) | ||
} | ||
|
||
// Error: | ||
// 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,28 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var bid boards.BoardID | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
bid = boards.CreateBoard("test_board") | ||
boards.CreateReply(bid, 0, 0, "Reply of the second post") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board")) | ||
} | ||
|
||
// 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,26 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var bid boards.BoardID | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
boards.CreateReply(bid, 0, 0, "Reply of the second post") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board")) | ||
} | ||
|
||
// Error: | ||
// 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,41 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
import ( | ||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
"std" | ||
) | ||
|
||
var bid boards.BoardID | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
err := users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") | ||
pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") | ||
boards.CreateReply(bid, pid, pid, "Reply of the second post") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board")) | ||
} | ||
|
||
// Output: | ||
// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)] | ||
// | ||
// ---------------------------------------- | ||
// ## [First Post (title)](/r/demo/boards:test_board/1) | ||
// | ||
// Body of the first post. (body) | ||
// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] (0 replies) (0 reposts) | ||
// | ||
// ---------------------------------------- | ||
// ## [Second Post (title)](/r/demo/boards:test_board/2) | ||
// | ||
// Body of the second post. (body) | ||
// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/2) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] (1 replies) (0 reposts) | ||
// | ||
// |
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,36 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
// boardId 2 not exist | ||
boards.DeletePost(2, pid, pid, "") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// Error: | ||
// 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,36 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
// pid of 2 not exist | ||
boards.DeletePost(bid, 2, 2, "") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// 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,51 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
rid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
rid = boards.CreateReply(bid, pid, pid, "First reply of the First post\n") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
boards.DeletePost(bid, pid, rid, "") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// Output: | ||
// # First Post in (title) | ||
// | ||
// Body of the first post. (body) | ||
// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] | ||
// | ||
// > First reply of the First post | ||
// > | ||
// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=2)] | ||
// | ||
// ---------------------------------------------------- | ||
// # First Post in (title) | ||
// | ||
// Body of the first post. (body) | ||
// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] | ||
// |
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,41 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
boards.DeletePost(bid, pid, pid, "") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// Output: | ||
// # First Post in (title) | ||
// | ||
// Body of the first post. (body) | ||
// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] | ||
// | ||
// ---------------------------------------------------- | ||
// thread does not exist with id: 1 |
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,36 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
// board 2 not exist | ||
boards.EditPost(2, pid, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// Error: | ||
// 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,36 @@ | ||
// PKGPATH: gno.land/r/demo/boards_test | ||
package boards_test | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
"strconv" | ||
|
||
"gno.land/r/demo/boards" | ||
users "gno.land/r/gnoland/users/v1" | ||
) | ||
|
||
var ( | ||
bid boards.BoardID | ||
pid boards.PostID | ||
) | ||
|
||
func init() { | ||
std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller | ||
users.Register("gnouser123") | ||
|
||
bid = boards.CreateBoard("test_board") | ||
pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") | ||
} | ||
|
||
func main() { | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
// thread 2 not exist | ||
boards.EditPost(bid, 2, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") | ||
println("----------------------------------------------------") | ||
println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) | ||
} | ||
|
||
// Error: | ||
// thread not exist |
Oops, something went wrong.