Skip to content

Commit

Permalink
test: add new filetests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Feb 11, 2025
1 parent ea4866e commit 877ed1a
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/gno.land/r/nt/boards2/v1/z_10_g_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"std"

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

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

var (
bid boards2.BoardID
pid boards2.PostID
)

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

boards2.SetFlaggingThreshold(bid, 2)
boards2.FlagThread(bid, pid, "")
}

func main() {
boards2.FlagThread(bid, pid, "")
}

// Error:
// item has been already flagged by a current user
26 changes: 26 additions & 0 deletions examples/gno.land/r/nt/boards2/v1/z_16_a_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"std"

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

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

var bid boards2.BoardID

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

func main() {
boards2.SetFlaggingThreshold(bid, 4)

// Ensure that flagging threshold changed
println(boards2.GetFlaggingThreshold(bid))
}

// Output:
// 4
22 changes: 22 additions & 0 deletions examples/gno.land/r/nt/boards2/v1/z_16_b_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"std"

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

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

const bid boards2.BoardID = 404

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

func main() {
boards2.SetFlaggingThreshold(bid, 1)
}

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

import (
"std"

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

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

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

func main() {
boards2.SetFlaggingThreshold(1, 0)
}

// Error:
// invalid flagging threshold

0 comments on commit 877ed1a

Please sign in to comment.