-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(gno/dao): add unit test for init dao
- Loading branch information
1 parent
4f7fab2
commit ba506a8
Showing
1 changed file
with
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dao_roles_based | ||
|
||
// Test Dao Creation (done) | ||
// Test Dao Has Role | ||
// Test Dao IsMember | ||
// Test Dao Proposal | ||
// Test Dao Vote | ||
// Test Dao Execute | ||
|
||
import "testing" | ||
|
||
func TestNewDaoRolesBasedJSON(t *testing.T) { | ||
name := "My DAO" | ||
description := "My DAO Description" | ||
roles := []string{"admin"} | ||
members := [][]string{{"0x1", "admin"}, {"0x2"}, {"0x3"}} | ||
resourcesJSON := `[]` | ||
handlers := []MessageHandler{} | ||
|
||
dao := NewDaoRolesBasedJSON(name, description, roles, members, resourcesJSON, handlers) | ||
roles = dao.MemberModule.GetRoles() | ||
if len(roles) != 1 { | ||
t.Errorf("Expected 1 role, got %d", len(roles)) | ||
} | ||
if roles[0] != "admin" { | ||
t.Errorf("Expected role 'admin', got %s", roles[0]) | ||
} | ||
|
||
for _, member := range members { | ||
address := member[0] | ||
if !dao.IsMember(address) { | ||
t.Errorf("Expected member %s to be a member", address) | ||
} | ||
if len(member) == 2 && !dao.HasRole(address, member[1]) { | ||
t.Errorf("Expected member %s to have role %s", address, member[1]) | ||
} | ||
} | ||
|
||
resourcesLen := dao.ResourcesModule.resources.Size() | ||
if resourcesLen != 0 { | ||
t.Errorf("Expected 0 resources, got %d", resourcesLen) | ||
} | ||
} |