mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Tests: Refactor command tests
This commit is contained in:
@@ -3,22 +3,13 @@ package commands
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/photoprism/photoprism/pkg/capture"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUsersResetCommand(t *testing.T) {
|
||||
t.Run("NotConfirmed", func(t *testing.T) {
|
||||
var err error
|
||||
|
||||
// Create test context with flags and arguments.
|
||||
args0 := []string{"ls"}
|
||||
ctx0 := NewTestContext(args0)
|
||||
|
||||
// Run command with test context.
|
||||
output0 := capture.Output(func() {
|
||||
err = UsersListCommand.Run(ctx0, args0...)
|
||||
})
|
||||
output0, err := RunWithTestContext(UsersListCommand, []string{"ls"})
|
||||
|
||||
// Check command output for plausibility.
|
||||
// t.Logf(output)
|
||||
@@ -26,14 +17,8 @@ func TestUsersResetCommand(t *testing.T) {
|
||||
assert.Contains(t, output0, "alice")
|
||||
assert.Contains(t, output0, "bob")
|
||||
|
||||
// Create test context with flags and arguments.
|
||||
args := []string{"reset"}
|
||||
ctx := NewTestContext(args)
|
||||
|
||||
// Run command with test context.
|
||||
output := capture.Output(func() {
|
||||
err = UsersResetCommand.Run(ctx, args...)
|
||||
})
|
||||
output, err := RunWithTestContext(UsersResetCommand, []string{"reset"})
|
||||
|
||||
// Check command output for plausibility.
|
||||
//t.Logf(output)
|
||||
@@ -41,9 +26,7 @@ func TestUsersResetCommand(t *testing.T) {
|
||||
assert.Empty(t, output)
|
||||
|
||||
// Run command with test context.
|
||||
output1 := capture.Output(func() {
|
||||
err = UsersListCommand.Run(ctx0, args0...)
|
||||
})
|
||||
output1, err := RunWithTestContext(UsersListCommand, []string{"ls"})
|
||||
|
||||
// Check command output for plausibility.
|
||||
// t.Logf(output)
|
||||
|
||||
Reference in New Issue
Block a user