Skip to content
Merged
Prev Previous commit
Next Next commit
Add unit test
  • Loading branch information
Emyrk committed May 3, 2022
commit 0efe72cfd76443ba4cbae7a38dd2771bd97a59aa
21 changes: 21 additions & 0 deletions coderd/rbac/builtin_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rbac_test

import (
"fmt"
"testing"

"github.com/google/uuid"
Expand Down Expand Up @@ -60,3 +61,23 @@ func TestIsOrgRole(t *testing.T) {
})
}
}

func TestListRoles(t *testing.T) {
t.Parallel()

// If this test is ever failing, just update the list to the roles
// expected from the builtin set.
require.ElementsMatch(t, []string{
"admin",
"member",
"auditor",
},
rbac.SiteRoles())

orgID := uuid.New()
require.ElementsMatch(t, []string{
fmt.Sprintf("organization-admin:%s", orgID.String()),
fmt.Sprintf("organization-member:%s", orgID.String()),
},
rbac.OrganizationRoles(orgID))
}