Files
photoprism/internal/commands/users_add_test.go
2024-12-09 15:11:39 +01:00

40 lines
1.1 KiB
Go

package commands
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUsersAddCommand(t *testing.T) {
t.Run("AddUserThatAlreadyExists", func(t *testing.T) {
// Run command with test context.
output, err := RunWithTestContext(UsersAddCommand, []string{"add", "--name=Alice", "--email=jane@test.de", "--password=test1234", "--role=admin", "alice"})
// Check command output for plausibility.
// t.Logf(output)
assert.Error(t, err)
assert.Empty(t, output)
})
t.Run("AddDeletedUser", func(t *testing.T) {
// Run command with test context.
output, err := RunWithTestContext(UsersAddCommand, []string{"add", "--name=deleted", "--password=test1234", "deleted"})
// Check command output for plausibility.
// t.Logf(output)
assert.Error(t, err)
assert.Empty(t, output)
})
t.Run("AddUsernameMissing", func(t *testing.T) {
// Run command with test context.
output, err := RunWithTestContext(UsersAddCommand, []string{"add", "--name=noname", "--password=test1234", "/##"})
// Check command output for plausibility.
// t.Logf(output)
assert.Error(t, err)
assert.Empty(t, output)
})
}