photoprism/internal/acl/role_test.go
Michael Mayer 3dec8f4f48 Run "make fmt"
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-12-19 15:43:29 +01:00

79 lines
1.8 KiB
Go

package acl
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRole_String(t *testing.T) {
t.Run("Admin", func(t *testing.T) {
assert.Equal(t, "admin", RoleAdmin.String())
})
t.Run("Client", func(t *testing.T) {
assert.Equal(t, "client", RoleClient.String())
})
t.Run("Visitor", func(t *testing.T) {
assert.Equal(t, "visitor", RoleVisitor.String())
})
}
func TestRole_Pretty(t *testing.T) {
t.Run("Admin", func(t *testing.T) {
assert.Equal(t, "Admin", RoleAdmin.Pretty())
})
t.Run("Unknown", func(t *testing.T) {
assert.Equal(t, "Unknown", RoleUnknown.Pretty())
})
t.Run("Visitor", func(t *testing.T) {
assert.Equal(t, "Visitor", RoleVisitor.Pretty())
})
}
func TestRole_LogId(t *testing.T) {
t.Run("Admin", func(t *testing.T) {
assert.Equal(t, "role admin", RoleAdmin.LogId())
})
t.Run("Client", func(t *testing.T) {
assert.Equal(t, "role client", RoleClient.LogId())
})
t.Run("Visitor", func(t *testing.T) {
assert.Equal(t, "role visitor", RoleVisitor.LogId())
})
}
func TestRole_Equal(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.True(t, RoleAdmin.Equal("admin"))
})
t.Run("False", func(t *testing.T) {
assert.False(t, RoleClient.Equal("admin"))
})
}
func TestRole_NotEqual(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.True(t, RoleClient.NotEqual("admin"))
})
t.Run("False", func(t *testing.T) {
assert.False(t, RoleAdmin.NotEqual("admin"))
})
}
func TestRole_Valid(t *testing.T) {
t.Run("True", func(t *testing.T) {
assert.True(t, RoleAdmin.Valid("admin"))
})
t.Run("False", func(t *testing.T) {
assert.False(t, RoleClient.Valid("client"))
})
}
func TestRole_Invalid(t *testing.T) {
t.Run("False", func(t *testing.T) {
assert.False(t, RoleAdmin.Invalid("admin"))
})
t.Run("True", func(t *testing.T) {
assert.True(t, RoleClient.Invalid("client"))
})
}