-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(boards2): add missing filetests for board rename (#3625)
Add a missing filetests for `RenameBoard()` function. Related to #3623. This covers all tests for the function: - Rename success by default board owner - Fail w/ empty board name - Fail w/ existing board name - Fail when renaming unexisting board - Fail w/ an address as board name - Rename success by another board owner - Fail because name is registered and not owned in `users` realm - Fail w/ short name - Rename success with owned name registered in `users` realm - Fail for non board DAO member
- Loading branch information
1 parent
69960ec
commit 33fb889
Showing
6 changed files
with
118 additions
and
32 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
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,24 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
name = "foo123" | ||
) | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
boards2.CreateBoard(name) | ||
} | ||
|
||
func main() { | ||
boards2.RenameBoard(name, "short") | ||
} | ||
|
||
// Error: | ||
// the minimum allowed board name length is 6 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,43 @@ | ||
package main | ||
|
||
// SEND: 200000000ugnot | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/users" | ||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
member = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
member2 = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5") | ||
name = "foo123" | ||
newName = "barbaz" | ||
) | ||
|
||
var bid boards2.BoardID // Operate on board DAO | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
|
||
bid = boards2.CreateBoard(name) | ||
boards2.InviteMember(bid, member, boards2.RoleOwner) | ||
|
||
// Test1 is the boards owner and its address has a user already registered | ||
// so a new member must register a user with the new board name. | ||
std.TestSetOrigCaller(member) | ||
users.Register("", newName, "") | ||
|
||
// Invite a new member that doesn't own the user that matches the new board name | ||
boards2.InviteMember(bid, member2, boards2.RoleOwner) | ||
std.TestSetOrigCaller(member2) | ||
} | ||
|
||
func main() { | ||
boards2.RenameBoard(name, newName) | ||
} | ||
|
||
// Error: | ||
// board name is a user name registered to a different user |
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 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
name = "foo123" | ||
) | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
boards2.CreateBoard(name) | ||
|
||
std.TestSetOrigCaller(user) | ||
} | ||
|
||
func main() { | ||
boards2.RenameBoard(name, "barbaz") | ||
} | ||
|
||
// Error: | ||
// unauthorized |