-
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 member invite (#3632)
Add missing filetests for `InviteMember()` function. Related to #3623 This covers all tests for the function: - Invite to realm success - Fail when admin invites a new realm owner - Success when admin invites a new realm admin - Fail w/ invalid invite role - Invite to board success - Fail w/ existing user - Fail for non member (unauthorized)
- Loading branch information
1 parent
33fb889
commit 90a3c4e
Showing
7 changed files
with
121 additions
and
14 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,23 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
) | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(0, user, boards2.Role("foobar")) // Operate on realm DAO instead of individual boards | ||
} | ||
|
||
// Error: | ||
// invalid role: foobar |
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 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
role = boards2.RoleOwner | ||
) | ||
|
||
var bid boards2.BoardID | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
bid = boards2.CreateBoard("foo123") // Operate on board DAO members | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(bid, user, role) | ||
|
||
// Check that user is invited | ||
println(boards2.HasMemberRole(0, user, role)) // Operate on realm DAO | ||
println(boards2.HasMemberRole(bid, user, role)) | ||
} | ||
|
||
// Output: | ||
// false | ||
// true |
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 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
user = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
bid = boards2.BoardID(0) // Operate on realm DAO instead of individual boards | ||
role = boards2.RoleOwner | ||
) | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
boards2.InviteMember(bid, user, role) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(bid, user, role) | ||
} | ||
|
||
// Error: | ||
// user already exists |
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,20 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/nt/boards2" | ||
) | ||
|
||
const owner = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(0, "g1w4ek2u33ta047h6lta047h6lta047h6ldvdwpn", boards2.RoleGuest) | ||
} | ||
|
||
// Error: | ||
// unauthorized |