Tests: Refactor command tests

This commit is contained in:
graciousgrey
2024-12-09 15:11:39 +01:00
parent e39ac1729a
commit 3f26d79380
26 changed files with 89 additions and 552 deletions

View File

@@ -3,22 +3,13 @@ package commands
import (
"testing"
"github.com/photoprism/photoprism/pkg/capture"
"github.com/stretchr/testify/assert"
)
func TestUsersRemoveCommand(t *testing.T) {
t.Run("RemoveNotExistingUser", func(t *testing.T) {
var err error
// Create test context with flags and arguments.
args := []string{"rm", "uqxqg7i1kperxxx0"}
ctx := NewTestContext(args)
// Run command with test context.
output := capture.Output(func() {
err = UsersRemoveCommand.Run(ctx, args...)
})
output, err := RunWithTestContext(UsersRemoveCommand, []string{"rm", "uqxqg7i1kperxxx0"})
// Check command output for plausibility.
// t.Logf(output)
@@ -26,16 +17,8 @@ func TestUsersRemoveCommand(t *testing.T) {
assert.Empty(t, output)
})
t.Run("RemoveDeletedUser", func(t *testing.T) {
var err error
// Create test context with flags and arguments.
args := []string{"rm", "deleted"}
ctx := NewTestContext(args)
// Run command with test context.
output := capture.Output(func() {
err = UsersRemoveCommand.Run(ctx, args...)
})
output, err := RunWithTestContext(UsersRemoveCommand, []string{"rm", "deleted"})
// Check command output for plausibility.
// t.Logf(output)