github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/teams/role_test.go (about) 1 package teams 2 3 import ( 4 "testing" 5 6 "github.com/keybase/client/go/protocol/keybase1" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestRoleOrder(t *testing.T) { 11 require.Len(t, keybase1.TeamRoleMap, 7, "you added a new role. Does the IsOrAbove relation still work?") 12 n := keybase1.TeamRole_NONE 13 rb := keybase1.TeamRole_RESTRICTEDBOT 14 b := keybase1.TeamRole_BOT 15 r := keybase1.TeamRole_READER 16 w := keybase1.TeamRole_WRITER 17 a := keybase1.TeamRole_ADMIN 18 o := keybase1.TeamRole_OWNER 19 20 require.Equal(t, false, n.IsReaderOrAbove()) 21 require.Equal(t, false, rb.IsReaderOrAbove()) 22 require.Equal(t, false, b.IsReaderOrAbove()) 23 require.Equal(t, true, r.IsReaderOrAbove()) 24 require.Equal(t, true, w.IsReaderOrAbove()) 25 require.Equal(t, true, a.IsReaderOrAbove()) 26 require.Equal(t, true, o.IsReaderOrAbove()) 27 28 require.Equal(t, false, n.IsAdminOrAbove()) 29 require.Equal(t, false, rb.IsAdminOrAbove()) 30 require.Equal(t, false, b.IsAdminOrAbove()) 31 require.Equal(t, false, r.IsAdminOrAbove()) 32 require.Equal(t, false, w.IsAdminOrAbove()) 33 require.Equal(t, true, a.IsAdminOrAbove()) 34 require.Equal(t, true, o.IsAdminOrAbove()) 35 36 order := func(r1, r2 keybase1.TeamRole) { 37 require.Equal(t, true, r2.IsOrAbove(r1)) 38 require.Equal(t, false, r1.IsOrAbove(r2)) 39 } 40 // spot check 41 order(n, rb) 42 order(n, b) 43 order(n, r) 44 order(n, w) 45 order(n, a) 46 order(n, o) 47 48 order(rb, b) 49 order(rb, r) 50 order(rb, w) 51 order(rb, a) 52 order(rb, o) 53 54 order(b, r) 55 order(b, w) 56 order(b, a) 57 order(b, o) 58 59 order(r, w) 60 order(r, a) 61 order(r, o) 62 63 order(w, o) 64 order(w, a) 65 }