Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(boards2): add missing filetests for thread deletion #3645

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add missing filetest for thread deletion
jeronimoalbi committed Jan 30, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 814caeccda891ef2da6b06efeb38532d02cf0445
34 changes: 34 additions & 0 deletions examples/gno.land/r/nt/boards2/z_9_a_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
title = "Test Thread"
body = "Test body"
)

var (
bid boards2.BoardID
pid boards2.PostID
)

func init() {
std.TestSetOrigCaller(owner)
bid = boards2.CreateBoard("test-board")
pid = boards2.CreateThread(bid, title, body)
}

func main() {
boards2.DeleteThread(bid, pid)

// Ensure thread doesn't exist
println(boards2.Render("test-board/1"))
}

// Output:
// Thread does not exist with ID: 1
20 changes: 20 additions & 0 deletions examples/gno.land/r/nt/boards2/z_9_b_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1

func init() {
std.TestSetOrigCaller(owner)
}

func main() {
boards2.DeleteThread(404, 1)
}

// Error:
// board does not exist with ID: 404
23 changes: 23 additions & 0 deletions examples/gno.land/r/nt/boards2/z_9_c_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1

var bid boards2.BoardID

func init() {
std.TestSetOrigCaller(owner)
bid = boards2.CreateBoard("test-board")
}

func main() {
boards2.DeleteThread(bid, 404)
}

// Error:
// thread does not exist with ID: 404
33 changes: 33 additions & 0 deletions examples/gno.land/r/nt/boards2/z_9_d_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
)

var (
bid boards2.BoardID
pid boards2.PostID
)

func init() {
std.TestSetOrigCaller(owner)
bid = boards2.CreateBoard("test-board")
pid = boards2.CreateThread(bid, "Foo", "bar")

// Call using a user that has not permission to delete threads
std.TestSetOrigCaller(user)
}

func main() {
boards2.DeleteThread(bid, pid)
}

// Error:
// unauthorized
37 changes: 37 additions & 0 deletions examples/gno.land/r/nt/boards2/z_9_e_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"std"

"gno.land/r/nt/boards2"
)

const (
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
)

var (
bid boards2.BoardID
pid boards2.PostID
)

func init() {
std.TestSetOrigCaller(owner)
bid = boards2.CreateBoard("test-board")
pid = boards2.CreateThread(bid, "Foo", "bar")

// Invite a member using a role with permission to delete threads
boards2.InviteMember(bid, member, boards2.RoleAdmin)
std.TestSetOrigCaller(member)
}

func main() {
boards2.DeleteThread(bid, pid)

// Ensure thread doesn't exist
println(boards2.Render("test-board/1"))
}

// Output:
// Thread does not exist with ID: 1