mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
CLI: Add RunWithTestContext function for command tests #3168
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -5,16 +5,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthCommands registers the API authentication subcommands.
|
// AuthCommands registers the API authentication subcommands.
|
||||||
var AuthCommands = cli.Command{
|
var AuthCommands = &cli.Command{
|
||||||
Name: "auth",
|
Name: "auth",
|
||||||
Aliases: []string{"sess"},
|
Aliases: []string{"sess"},
|
||||||
Usage: "API authentication subcommands",
|
Usage: "API authentication subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
&AuthListCommand,
|
AuthListCommand,
|
||||||
&AuthAddCommand,
|
AuthAddCommand,
|
||||||
&AuthShowCommand,
|
AuthShowCommand,
|
||||||
&AuthRemoveCommand,
|
AuthRemoveCommand,
|
||||||
&AuthResetCommand,
|
AuthResetCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var AuthAddFlags = []cli.Flag{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AuthAddCommand configures the command name, flags, and action.
|
// AuthAddCommand configures the command name, flags, and action.
|
||||||
var AuthAddCommand = cli.Command{
|
var AuthAddCommand = &cli.Command{
|
||||||
Name: "add",
|
Name: "add",
|
||||||
Usage: "Adds a new authentication secret for client applications",
|
Usage: "Adds a new authentication secret for client applications",
|
||||||
Description: "If you specify a username as argument, an app password will be created for this user account." +
|
Description: "If you specify a username as argument, an app password will be created for this user account." +
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthListCommand configures the command name, flags, and action.
|
// AuthListCommand configures the command name, flags, and action.
|
||||||
var AuthListCommand = cli.Command{
|
var AuthListCommand = &cli.Command{
|
||||||
Name: "ls",
|
Name: "ls",
|
||||||
Usage: "Lists currently authenticated users and clients",
|
Usage: "Lists currently authenticated users and clients",
|
||||||
ArgsUsage: "[search]",
|
ArgsUsage: "[search]",
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime/debug"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/photoprism/photoprism/pkg/capture"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAuthListCommand(t *testing.T) {
|
func TestAuthListCommand(t *testing.T) {
|
||||||
t.Run("All", func(t *testing.T) {
|
t.Run("All", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -31,16 +19,8 @@ func TestAuthListCommand(t *testing.T) {
|
|||||||
assert.Contains(t, output, "visitor ")
|
assert.Contains(t, output, "visitor ")
|
||||||
})
|
})
|
||||||
t.Run("Alice", func(t *testing.T) {
|
t.Run("Alice", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "alice"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls", "alice"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -52,16 +32,8 @@ func TestAuthListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "| Preview Token |")
|
assert.NotContains(t, output, "| Preview Token |")
|
||||||
})
|
})
|
||||||
t.Run("CSV", func(t *testing.T) {
|
t.Run("CSV", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--csv", "alice"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls", "--csv", "alice"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
//t.Logf(output)
|
//t.Logf(output)
|
||||||
@@ -72,16 +44,8 @@ func TestAuthListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("Tokens", func(t *testing.T) {
|
t.Run("Tokens", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--tokens", "alice"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls", "--tokens", "alice"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -93,16 +57,8 @@ func TestAuthListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("NoResult", func(t *testing.T) {
|
t.Run("NoResult", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--tokens", "notexisting"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls", "--tokens", "notexisting"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -110,27 +66,12 @@ func TestAuthListCommand(t *testing.T) {
|
|||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
})
|
})
|
||||||
t.Run("Error", func(t *testing.T) {
|
t.Run("Error", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
err = fmt.Errorf("error: %s \nstack: %s", r, debug.Stack())
|
|
||||||
assert.Error(t, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--xyz", "alice"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(AuthListCommand, []string{"ls", "--xyz", "alice"})
|
||||||
err = AuthListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthRemoveCommand configures the command name, flags, and action.
|
// AuthRemoveCommand configures the command name, flags, and action.
|
||||||
var AuthRemoveCommand = cli.Command{
|
var AuthRemoveCommand = &cli.Command{
|
||||||
Name: "rm",
|
Name: "rm",
|
||||||
Usage: "Deletes a session by id or access token",
|
Usage: "Deletes a session by id or access token",
|
||||||
ArgsUsage: "[identifier]",
|
ArgsUsage: "[identifier]",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
const AuthResetDescription = "This command recreates the auth_sessions database table so that it is compatible with the current version. As a result, all users and clients must re-authenticate. Note that any client access tokens and app passwords that users may have created are also deleted and must be recreated."
|
const AuthResetDescription = "This command recreates the auth_sessions database table so that it is compatible with the current version. As a result, all users and clients must re-authenticate. Note that any client access tokens and app passwords that users may have created are also deleted and must be recreated."
|
||||||
|
|
||||||
// AuthResetCommand configures the command name, flags, and action.
|
// AuthResetCommand configures the command name, flags, and action.
|
||||||
var AuthResetCommand = cli.Command{
|
var AuthResetCommand = &cli.Command{
|
||||||
Name: "reset",
|
Name: "reset",
|
||||||
Usage: "Resets the authentication of all users and clients",
|
Usage: "Resets the authentication of all users and clients",
|
||||||
Description: AuthResetDescription,
|
Description: AuthResetDescription,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AuthShowCommand configures the command name, flags, and action.
|
// AuthShowCommand configures the command name, flags, and action.
|
||||||
var AuthShowCommand = cli.Command{
|
var AuthShowCommand = &cli.Command{
|
||||||
Name: "show",
|
Name: "show",
|
||||||
Usage: "Shows detailed information about a session",
|
Usage: "Shows detailed information about a session",
|
||||||
ArgsUsage: "[identifier]",
|
ArgsUsage: "[identifier]",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const backupDescription = `A custom filename for the database backup (or - to se
|
|||||||
will be automatically determined based on the current configuration.`
|
will be automatically determined based on the current configuration.`
|
||||||
|
|
||||||
// BackupCommand configures the command name, flags, and action.
|
// BackupCommand configures the command name, flags, and action.
|
||||||
var BackupCommand = cli.Command{
|
var BackupCommand = &cli.Command{
|
||||||
Name: "backup",
|
Name: "backup",
|
||||||
Description: backupDescription,
|
Description: backupDescription,
|
||||||
Usage: "Creates an index database backup and/or album YAML backup files",
|
Usage: "Creates an index database backup and/or album YAML backup files",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CleanUpCommand configures the command name, flags, and action.
|
// CleanUpCommand configures the command name, flags, and action.
|
||||||
var CleanUpCommand = cli.Command{
|
var CleanUpCommand = &cli.Command{
|
||||||
Name: "cleanup",
|
Name: "cleanup",
|
||||||
Usage: "Removes orphaned index entries, sidecar and thumbnail files",
|
Usage: "Removes orphaned index entries, sidecar and thumbnail files",
|
||||||
Flags: cleanUpFlags,
|
Flags: cleanUpFlags,
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsCommands configures the client application subcommands.
|
// ClientsCommands configures the client application subcommands.
|
||||||
var ClientsCommands = cli.Command{
|
var ClientsCommands = &cli.Command{
|
||||||
Name: "clients",
|
Name: "clients",
|
||||||
Aliases: []string{"client"},
|
Aliases: []string{"client"},
|
||||||
Usage: "Client credentials subcommands",
|
Usage: "Client credentials subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
&ClientsListCommand,
|
ClientsListCommand,
|
||||||
&ClientsAddCommand,
|
ClientsAddCommand,
|
||||||
&ClientsShowCommand,
|
ClientsShowCommand,
|
||||||
&ClientsModCommand,
|
ClientsModCommand,
|
||||||
&ClientsRemoveCommand,
|
ClientsRemoveCommand,
|
||||||
&ClientsResetCommand,
|
ClientsResetCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsAddCommand configures the command name, flags, and action.
|
// ClientsAddCommand configures the command name, flags, and action.
|
||||||
var ClientsAddCommand = cli.Command{
|
var ClientsAddCommand = &cli.Command{
|
||||||
Name: "add",
|
Name: "add",
|
||||||
Usage: "Registers a new client application",
|
Usage: "Registers a new client application",
|
||||||
Description: "If you specify a username as argument, the new client will belong to this user and inherit its privileges.",
|
Description: "If you specify a username as argument, the new client will belong to this user and inherit its privileges.",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsListCommand configures the command name, flags, and action.
|
// ClientsListCommand configures the command name, flags, and action.
|
||||||
var ClientsListCommand = cli.Command{
|
var ClientsListCommand = &cli.Command{
|
||||||
Name: "ls",
|
Name: "ls",
|
||||||
Usage: "Lists registered client applications",
|
Usage: "Lists registered client applications",
|
||||||
ArgsUsage: "[search]",
|
ArgsUsage: "[search]",
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime/debug"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/photoprism/photoprism/pkg/capture"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClientsListCommand(t *testing.T) {
|
func TestClientsListCommand(t *testing.T) {
|
||||||
t.Run("All", func(t *testing.T) {
|
t.Run("All", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(ClientsListCommand, []string{"ls"})
|
||||||
err = ClientsListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -32,16 +20,8 @@ func TestClientsListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("Monitoring", func(t *testing.T) {
|
t.Run("Monitoring", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "monitoring"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(ClientsListCommand, []string{"ls", "monitoring"})
|
||||||
err = ClientsListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -53,16 +33,8 @@ func TestClientsListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("CSV", func(t *testing.T) {
|
t.Run("CSV", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--csv", "monitoring"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(ClientsListCommand, []string{"ls", "--csv", "monitoring"})
|
||||||
err = ClientsListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -74,16 +46,8 @@ func TestClientsListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "alice")
|
assert.NotContains(t, output, "alice")
|
||||||
})
|
})
|
||||||
t.Run("NoResult", func(t *testing.T) {
|
t.Run("NoResult", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "notexisting"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(ClientsListCommand, []string{"ls", "notexisting"})
|
||||||
err = ClientsListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -91,27 +55,12 @@ func TestClientsListCommand(t *testing.T) {
|
|||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
})
|
})
|
||||||
t.Run("Error", func(t *testing.T) {
|
t.Run("Error", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
err = fmt.Errorf("error: %s \nstack: %s", r, debug.Stack())
|
|
||||||
assert.Error(t, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--xyz", "monitoring"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(ClientsListCommand, []string{"ls", "--xyz", "monitoring"})
|
||||||
err = ClientsListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsModCommand configures the command name, flags, and action.
|
// ClientsModCommand configures the command name, flags, and action.
|
||||||
var ClientsModCommand = cli.Command{
|
var ClientsModCommand = &cli.Command{
|
||||||
Name: "mod",
|
Name: "mod",
|
||||||
Usage: "Updates client application settings",
|
Usage: "Updates client application settings",
|
||||||
ArgsUsage: "[client id]",
|
ArgsUsage: "[client id]",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsRemoveCommand configures the command name, flags, and action.
|
// ClientsRemoveCommand configures the command name, flags, and action.
|
||||||
var ClientsRemoveCommand = cli.Command{
|
var ClientsRemoveCommand = &cli.Command{
|
||||||
Name: "rm",
|
Name: "rm",
|
||||||
Usage: "Deletes the specified client application",
|
Usage: "Deletes the specified client application",
|
||||||
ArgsUsage: "[client id]",
|
ArgsUsage: "[client id]",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsResetCommand configures the command name, flags, and action.
|
// ClientsResetCommand configures the command name, flags, and action.
|
||||||
var ClientsResetCommand = cli.Command{
|
var ClientsResetCommand = &cli.Command{
|
||||||
Name: "reset",
|
Name: "reset",
|
||||||
Usage: "Removes all registered client applications",
|
Usage: "Removes all registered client applications",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ClientsShowCommand configures the command name, flags, and action.
|
// ClientsShowCommand configures the command name, flags, and action.
|
||||||
var ClientsShowCommand = cli.Command{
|
var ClientsShowCommand = &cli.Command{
|
||||||
Name: "show",
|
Name: "show",
|
||||||
Usage: "Shows client configuration details",
|
Usage: "Shows client configuration details",
|
||||||
ArgsUsage: "[client id]",
|
ArgsUsage: "[client id]",
|
||||||
|
|||||||
@@ -41,35 +41,35 @@ var log = event.Log
|
|||||||
|
|
||||||
// PhotoPrism contains the photoprism CLI (sub-)commands.
|
// PhotoPrism contains the photoprism CLI (sub-)commands.
|
||||||
var PhotoPrism = []*cli.Command{
|
var PhotoPrism = []*cli.Command{
|
||||||
&StartCommand,
|
StartCommand,
|
||||||
&StopCommand,
|
StopCommand,
|
||||||
&StatusCommand,
|
StatusCommand,
|
||||||
&IndexCommand,
|
IndexCommand,
|
||||||
&FindCommand,
|
FindCommand,
|
||||||
&ImportCommand,
|
ImportCommand,
|
||||||
&CopyCommand,
|
CopyCommand,
|
||||||
&FacesCommands,
|
FacesCommands,
|
||||||
&PlacesCommands,
|
PlacesCommands,
|
||||||
&PurgeCommand,
|
PurgeCommand,
|
||||||
&CleanUpCommand,
|
CleanUpCommand,
|
||||||
&OptimizeCommand,
|
OptimizeCommand,
|
||||||
&MomentsCommand,
|
MomentsCommand,
|
||||||
&ConvertCommand,
|
ConvertCommand,
|
||||||
&ThumbsCommand,
|
ThumbsCommand,
|
||||||
&MigrateCommand,
|
MigrateCommand,
|
||||||
&MigrationsCommands,
|
MigrationsCommands,
|
||||||
&BackupCommand,
|
BackupCommand,
|
||||||
&RestoreCommand,
|
RestoreCommand,
|
||||||
&ResetCommand,
|
ResetCommand,
|
||||||
&PasswdCommand,
|
PasswdCommand,
|
||||||
&UsersCommands,
|
UsersCommands,
|
||||||
&ClientsCommands,
|
ClientsCommands,
|
||||||
&AuthCommands,
|
AuthCommands,
|
||||||
&ShowCommands,
|
ShowCommands,
|
||||||
&VersionCommand,
|
VersionCommand,
|
||||||
&EditionCommand,
|
EditionCommand,
|
||||||
&ShowConfigCommand,
|
ShowConfigCommand,
|
||||||
&ConnectCommand,
|
ConnectCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountFlag represents a CLI flag to limit the number of report rows.
|
// CountFlag represents a CLI flag to limit the number of report rows.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/photoprism/photoprism/internal/config"
|
"github.com/photoprism/photoprism/internal/config"
|
||||||
"github.com/photoprism/photoprism/internal/event"
|
"github.com/photoprism/photoprism/internal/event"
|
||||||
"github.com/photoprism/photoprism/internal/photoprism/get"
|
"github.com/photoprism/photoprism/internal/photoprism/get"
|
||||||
|
"github.com/photoprism/photoprism/pkg/capture"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
@@ -30,14 +31,14 @@ func TestMain(m *testing.M) {
|
|||||||
code := m.Run()
|
code := m.Run()
|
||||||
|
|
||||||
// Close database connection.
|
// Close database connection.
|
||||||
c.CloseDb()
|
_ = c.CloseDb()
|
||||||
|
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTestContext creates a new CLI test context with the flags and arguments provided.
|
// NewTestContext creates a new CLI test context with the flags and arguments provided.
|
||||||
func NewTestContext(args []string) *cli.Context {
|
func NewTestContext(args []string) *cli.Context {
|
||||||
// Create new command-line app.
|
// Create new command-line test app.
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "photoprism"
|
app.Name = "photoprism"
|
||||||
app.Usage = "PhotoPrism®"
|
app.Usage = "PhotoPrism®"
|
||||||
@@ -46,6 +47,11 @@ func NewTestContext(args []string) *cli.Context {
|
|||||||
app.Copyright = "(c) 2018-2024 PhotoPrism UG. All rights reserved."
|
app.Copyright = "(c) 2018-2024 PhotoPrism UG. All rights reserved."
|
||||||
app.Flags = config.Flags.Cli()
|
app.Flags = config.Flags.Cli()
|
||||||
app.Commands = PhotoPrism
|
app.Commands = PhotoPrism
|
||||||
|
app.HelpName = app.Name
|
||||||
|
app.CustomAppHelpTemplate = ""
|
||||||
|
app.HideHelp = true
|
||||||
|
app.HideHelpCommand = true
|
||||||
|
app.Action = func(*cli.Context) error { return nil }
|
||||||
app.EnableBashCompletion = false
|
app.EnableBashCompletion = false
|
||||||
app.Metadata = map[string]interface{}{
|
app.Metadata = map[string]interface{}{
|
||||||
"Name": "PhotoPrism",
|
"Name": "PhotoPrism",
|
||||||
@@ -54,10 +60,27 @@ func NewTestContext(args []string) *cli.Context {
|
|||||||
"Version": "test",
|
"Version": "test",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse command arguments.
|
// Parse command test arguments.
|
||||||
set := flag.NewFlagSet("test", flag.ContinueOnError)
|
flagSet := flag.NewFlagSet("test", flag.ContinueOnError)
|
||||||
LogErr(set.Parse(args))
|
LogErr(flagSet.Parse(args))
|
||||||
|
|
||||||
// Create and return new context.
|
// Create and return new test context.
|
||||||
return cli.NewContext(app, set, nil)
|
return cli.NewContext(app, flagSet, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunWithTestContext executes a command with a test context and returns its output.
|
||||||
|
func RunWithTestContext(cmd *cli.Command, args []string) (output string, err error) {
|
||||||
|
// Create test context with flags and arguments.
|
||||||
|
ctx := NewTestContext(args)
|
||||||
|
|
||||||
|
// TODO: Help output can currently not be generated in test mode due to
|
||||||
|
// a nil pointer panic in the "github.com/urfave/cli/v2" package.
|
||||||
|
cmd.HideHelp = true
|
||||||
|
|
||||||
|
// Run command with test context.
|
||||||
|
output = capture.Output(func() {
|
||||||
|
err = cmd.Run(ctx, args...)
|
||||||
|
})
|
||||||
|
|
||||||
|
return output, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ConnectCommand configures the command name, flags, and action.
|
// ConnectCommand configures the command name, flags, and action.
|
||||||
var ConnectCommand = cli.Command{
|
var ConnectCommand = &cli.Command{
|
||||||
Name: "connect",
|
Name: "connect",
|
||||||
Usage: "Connects your membership account",
|
Usage: "Connects your membership account",
|
||||||
ArgsUsage: "[activation code]",
|
ArgsUsage: "[activation code]",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ConvertCommand configures the command name, flags, and action.
|
// ConvertCommand configures the command name, flags, and action.
|
||||||
var ConvertCommand = cli.Command{
|
var ConvertCommand = &cli.Command{
|
||||||
Name: "convert",
|
Name: "convert",
|
||||||
Usage: "Converts files in other formats to JPEG and AVC as needed",
|
Usage: "Converts files in other formats to JPEG and AVC as needed",
|
||||||
ArgsUsage: "[subfolder]",
|
ArgsUsage: "[subfolder]",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CopyCommand configures the command name, flags, and action.
|
// CopyCommand configures the command name, flags, and action.
|
||||||
var CopyCommand = cli.Command{
|
var CopyCommand = &cli.Command{
|
||||||
Name: "cp",
|
Name: "cp",
|
||||||
Aliases: []string{"copy"},
|
Aliases: []string{"copy"},
|
||||||
Usage: "Copies media files to originals",
|
Usage: "Copies media files to originals",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// EditionCommand configures the "photoprism edition" command.
|
// EditionCommand configures the "photoprism edition" command.
|
||||||
var EditionCommand = cli.Command{
|
var EditionCommand = &cli.Command{
|
||||||
Name: "edition",
|
Name: "edition",
|
||||||
Usage: "Shows edition information",
|
Usage: "Shows edition information",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// FacesCommands configures the command name, flags, and action.
|
// FacesCommands configures the command name, flags, and action.
|
||||||
var FacesCommands = cli.Command{
|
var FacesCommands = &cli.Command{
|
||||||
Name: "faces",
|
Name: "faces",
|
||||||
Usage: "Face recognition subcommands",
|
Usage: "Face recognition subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// FindCommand configures the command name, flags, and action.
|
// FindCommand configures the command name, flags, and action.
|
||||||
var FindCommand = cli.Command{
|
var FindCommand = &cli.Command{
|
||||||
Name: "find",
|
Name: "find",
|
||||||
Usage: "Searches the index for specific files",
|
Usage: "Searches the index for specific files",
|
||||||
ArgsUsage: "filter",
|
ArgsUsage: "filter",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ImportCommand configures the command name, flags, and action.
|
// ImportCommand configures the command name, flags, and action.
|
||||||
var ImportCommand = cli.Command{
|
var ImportCommand = &cli.Command{
|
||||||
Name: "mv",
|
Name: "mv",
|
||||||
Aliases: []string{"import"},
|
Aliases: []string{"import"},
|
||||||
Usage: "Moves media files to originals",
|
Usage: "Moves media files to originals",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// IndexCommand registers the index cli command.
|
// IndexCommand registers the index cli command.
|
||||||
var IndexCommand = cli.Command{
|
var IndexCommand = &cli.Command{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
Usage: "Indexes original media files",
|
Usage: "Indexes original media files",
|
||||||
ArgsUsage: "[subfolder]",
|
ArgsUsage: "[subfolder]",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package commands
|
|||||||
import "github.com/urfave/cli/v2"
|
import "github.com/urfave/cli/v2"
|
||||||
|
|
||||||
// MigrateCommand configures the command name, flags, and action.
|
// MigrateCommand configures the command name, flags, and action.
|
||||||
var MigrateCommand = cli.Command{
|
var MigrateCommand = &cli.Command{
|
||||||
Name: "migrate",
|
Name: "migrate",
|
||||||
Usage: MigrationsRunCommand.Usage,
|
Usage: MigrationsRunCommand.Usage,
|
||||||
ArgsUsage: MigrationsRunCommand.ArgsUsage,
|
ArgsUsage: MigrationsRunCommand.ArgsUsage,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/photoprism/photoprism/pkg/txt/report"
|
"github.com/photoprism/photoprism/pkg/txt/report"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MigrationsStatusCommand = cli.Command{
|
var MigrationsStatusCommand = &cli.Command{
|
||||||
Name: "ls",
|
Name: "ls",
|
||||||
Aliases: []string{"status", "show"},
|
Aliases: []string{"status", "show"},
|
||||||
Usage: "Displays the status of schema migrations",
|
Usage: "Displays the status of schema migrations",
|
||||||
@@ -25,7 +25,7 @@ var MigrationsStatusCommand = cli.Command{
|
|||||||
Action: migrationsStatusAction,
|
Action: migrationsStatusAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
var MigrationsRunCommand = cli.Command{
|
var MigrationsRunCommand = &cli.Command{
|
||||||
Name: "run",
|
Name: "run",
|
||||||
Aliases: []string{"execute", "migrate"},
|
Aliases: []string{"execute", "migrate"},
|
||||||
Usage: "Executes database schema migrations",
|
Usage: "Executes database schema migrations",
|
||||||
@@ -46,12 +46,12 @@ var MigrationsRunCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MigrationsCommands registers the "migrations" CLI command.
|
// MigrationsCommands registers the "migrations" CLI command.
|
||||||
var MigrationsCommands = cli.Command{
|
var MigrationsCommands = &cli.Command{
|
||||||
Name: "migrations",
|
Name: "migrations",
|
||||||
Usage: "Database schema migration subcommands",
|
Usage: "Database schema migration subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
&MigrationsStatusCommand,
|
MigrationsStatusCommand,
|
||||||
&MigrationsRunCommand,
|
MigrationsRunCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MomentsCommand configures the command name, flags, and action.
|
// MomentsCommand configures the command name, flags, and action.
|
||||||
var MomentsCommand = cli.Command{
|
var MomentsCommand = &cli.Command{
|
||||||
Name: "moments",
|
Name: "moments",
|
||||||
Usage: "Creates albums of special moments, trips, and places",
|
Usage: "Creates albums of special moments, trips, and places",
|
||||||
Action: momentsAction,
|
Action: momentsAction,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// OptimizeCommand configures the command name, flags, and action.
|
// OptimizeCommand configures the command name, flags, and action.
|
||||||
var OptimizeCommand = cli.Command{
|
var OptimizeCommand = &cli.Command{
|
||||||
Name: "optimize",
|
Name: "optimize",
|
||||||
Usage: "Maintains titles, estimates, and other metadata",
|
Usage: "Maintains titles, estimates, and other metadata",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PasswdCommand configures the command name, flags, and action.
|
// PasswdCommand configures the command name, flags, and action.
|
||||||
var PasswdCommand = cli.Command{
|
var PasswdCommand = &cli.Command{
|
||||||
Name: "passwd",
|
Name: "passwd",
|
||||||
Usage: "Changes the local account password of a registered user",
|
Usage: "Changes the local account password of a registered user",
|
||||||
ArgsUsage: "[username]",
|
ArgsUsage: "[username]",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PlacesCommands configures the command name, flags, and action.
|
// PlacesCommands configures the command name, flags, and action.
|
||||||
var PlacesCommands = cli.Command{
|
var PlacesCommands = &cli.Command{
|
||||||
Name: "places",
|
Name: "places",
|
||||||
Usage: "Maps and location information subcommands",
|
Usage: "Maps and location information subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PurgeCommand configures the command name, flags, and action.
|
// PurgeCommand configures the command name, flags, and action.
|
||||||
var PurgeCommand = cli.Command{
|
var PurgeCommand = &cli.Command{
|
||||||
Name: "purge",
|
Name: "purge",
|
||||||
Usage: "Updates missing files, photo counts, and album covers",
|
Usage: "Updates missing files, photo counts, and album covers",
|
||||||
Flags: purgeFlags,
|
Flags: purgeFlags,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ResetCommand configures the command name, flags, and action.
|
// ResetCommand configures the command name, flags, and action.
|
||||||
var ResetCommand = cli.Command{
|
var ResetCommand = &cli.Command{
|
||||||
Name: "reset",
|
Name: "reset",
|
||||||
Usage: "Resets the index, clears the cache, and removes sidecar files",
|
Usage: "Resets the index, clears the cache, and removes sidecar files",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const restoreDescription = `A custom filename for the database backup (or - to r
|
|||||||
will be automatically determined based on the current configuration.`
|
will be automatically determined based on the current configuration.`
|
||||||
|
|
||||||
// RestoreCommand configures the command name, flags, and action.
|
// RestoreCommand configures the command name, flags, and action.
|
||||||
var RestoreCommand = cli.Command{
|
var RestoreCommand = &cli.Command{
|
||||||
Name: "restore",
|
Name: "restore",
|
||||||
Description: restoreDescription,
|
Description: restoreDescription,
|
||||||
Usage: "Restores the index database and/or album metadata from a backup",
|
Usage: "Restores the index database and/or album metadata from a backup",
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowCommands configures the show subcommands.
|
// ShowCommands configures the show subcommands.
|
||||||
var ShowCommands = cli.Command{
|
var ShowCommands = &cli.Command{
|
||||||
Name: "show",
|
Name: "show",
|
||||||
Usage: "Shows supported formats, features, and config options",
|
Usage: "Shows supported formats, features, and config options",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
&ShowConfigCommand,
|
ShowConfigCommand,
|
||||||
&ShowConfigOptionsCommand,
|
ShowConfigOptionsCommand,
|
||||||
&ShowConfigYamlCommand,
|
ShowConfigYamlCommand,
|
||||||
&ShowSearchFiltersCommand,
|
ShowSearchFiltersCommand,
|
||||||
&ShowFileFormatsCommand,
|
ShowFileFormatsCommand,
|
||||||
&ShowThumbSizesCommand,
|
ShowThumbSizesCommand,
|
||||||
&ShowVideoSizesCommand,
|
ShowVideoSizesCommand,
|
||||||
&ShowMetadataCommand,
|
ShowMetadataCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowConfigCommand configures the command name, flags, and action.
|
// ShowConfigCommand configures the command name, flags, and action.
|
||||||
var ShowConfigCommand = cli.Command{
|
var ShowConfigCommand = &cli.Command{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Usage: "Displays global config options and their current values",
|
Usage: "Displays global config options and their current values",
|
||||||
Flags: report.CliFlags,
|
Flags: report.CliFlags,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowConfigOptionsCommand configures the command name, flags, and action.
|
// ShowConfigOptionsCommand configures the command name, flags, and action.
|
||||||
var ShowConfigOptionsCommand = cli.Command{
|
var ShowConfigOptionsCommand = &cli.Command{
|
||||||
Name: "config-options",
|
Name: "config-options",
|
||||||
Usage: "Displays supported environment variables and CLI flags",
|
Usage: "Displays supported environment variables and CLI flags",
|
||||||
Flags: report.CliFlags,
|
Flags: report.CliFlags,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowConfigYamlCommand configures the command name, flags, and action.
|
// ShowConfigYamlCommand configures the command name, flags, and action.
|
||||||
var ShowConfigYamlCommand = cli.Command{
|
var ShowConfigYamlCommand = &cli.Command{
|
||||||
Name: "config-yaml",
|
Name: "config-yaml",
|
||||||
Usage: "Displays supported YAML config options and CLI flags",
|
Usage: "Displays supported YAML config options and CLI flags",
|
||||||
Flags: report.CliFlags,
|
Flags: report.CliFlags,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowFileFormatsCommand configures the command name, flags, and action.
|
// ShowFileFormatsCommand configures the command name, flags, and action.
|
||||||
var ShowFileFormatsCommand = cli.Command{
|
var ShowFileFormatsCommand = &cli.Command{
|
||||||
Name: "file-formats",
|
Name: "file-formats",
|
||||||
Aliases: []string{"formats"},
|
Aliases: []string{"formats"},
|
||||||
Usage: "Displays supported media and sidecar file formats",
|
Usage: "Displays supported media and sidecar file formats",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowMetadataCommand configures the command name, flags, and action.
|
// ShowMetadataCommand configures the command name, flags, and action.
|
||||||
var ShowMetadataCommand = cli.Command{
|
var ShowMetadataCommand = &cli.Command{
|
||||||
Name: "metadata",
|
Name: "metadata",
|
||||||
Aliases: []string{"meta"},
|
Aliases: []string{"meta"},
|
||||||
Usage: "Displays supported metadata tags and standards",
|
Usage: "Displays supported metadata tags and standards",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowSearchFiltersCommand configures the command name, flags, and action.
|
// ShowSearchFiltersCommand configures the command name, flags, and action.
|
||||||
var ShowSearchFiltersCommand = cli.Command{
|
var ShowSearchFiltersCommand = &cli.Command{
|
||||||
Name: "search-filters",
|
Name: "search-filters",
|
||||||
Usage: "Displays supported search filters with examples",
|
Usage: "Displays supported search filters with examples",
|
||||||
Flags: report.CliFlags,
|
Flags: report.CliFlags,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowThumbSizesCommand configures the command name, flags, and action.
|
// ShowThumbSizesCommand configures the command name, flags, and action.
|
||||||
var ShowThumbSizesCommand = cli.Command{
|
var ShowThumbSizesCommand = &cli.Command{
|
||||||
Name: "thumb-sizes",
|
Name: "thumb-sizes",
|
||||||
Aliases: []string{"thumbs"},
|
Aliases: []string{"thumbs"},
|
||||||
Usage: "Displays supported thumbnail types and sizes",
|
Usage: "Displays supported thumbnail types and sizes",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ShowVideoSizesCommand configures the command name, flags, and action.
|
// ShowVideoSizesCommand configures the command name, flags, and action.
|
||||||
var ShowVideoSizesCommand = cli.Command{
|
var ShowVideoSizesCommand = &cli.Command{
|
||||||
Name: "video-sizes",
|
Name: "video-sizes",
|
||||||
Usage: "Displays supported standard video sizes",
|
Usage: "Displays supported standard video sizes",
|
||||||
Flags: report.CliFlags,
|
Flags: report.CliFlags,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// StartCommand configures the command name, flags, and action.
|
// StartCommand configures the command name, flags, and action.
|
||||||
var StartCommand = cli.Command{
|
var StartCommand = &cli.Command{
|
||||||
Name: "start",
|
Name: "start",
|
||||||
Aliases: []string{"up"},
|
Aliases: []string{"up"},
|
||||||
Usage: "Starts the Web server",
|
Usage: "Starts the Web server",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// StatusCommand configures the command name, flags, and action.
|
// StatusCommand configures the command name, flags, and action.
|
||||||
var StatusCommand = cli.Command{
|
var StatusCommand = &cli.Command{
|
||||||
Name: "status",
|
Name: "status",
|
||||||
Usage: "Checks if the Web server is running",
|
Usage: "Checks if the Web server is running",
|
||||||
Action: statusAction,
|
Action: statusAction,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// StopCommand configures the command name, flags, and action.
|
// StopCommand configures the command name, flags, and action.
|
||||||
var StopCommand = cli.Command{
|
var StopCommand = &cli.Command{
|
||||||
Name: "stop",
|
Name: "stop",
|
||||||
Aliases: []string{"down"},
|
Aliases: []string{"down"},
|
||||||
Usage: "Stops the Web server in daemon mode",
|
Usage: "Stops the Web server in daemon mode",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ThumbsCommand configures the command name, flags, and action.
|
// ThumbsCommand configures the command name, flags, and action.
|
||||||
var ThumbsCommand = cli.Command{
|
var ThumbsCommand = &cli.Command{
|
||||||
Name: "thumbs",
|
Name: "thumbs",
|
||||||
Usage: "(Re-)generates thumbnails based on the current configuration",
|
Usage: "(Re-)generates thumbnails based on the current configuration",
|
||||||
ArgsUsage: "[subfolder]",
|
ArgsUsage: "[subfolder]",
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersCommands configures the user management subcommands.
|
// UsersCommands configures the user management subcommands.
|
||||||
var UsersCommands = cli.Command{
|
var UsersCommands = &cli.Command{
|
||||||
Name: "users",
|
Name: "users",
|
||||||
Aliases: []string{"user"},
|
Aliases: []string{"user"},
|
||||||
Usage: "User management subcommands",
|
Usage: "User management subcommands",
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
&UsersListCommand,
|
UsersListCommand,
|
||||||
&UsersLegacyCommand,
|
UsersLegacyCommand,
|
||||||
&UsersAddCommand,
|
UsersAddCommand,
|
||||||
&UsersShowCommand,
|
UsersShowCommand,
|
||||||
&UsersModCommand,
|
UsersModCommand,
|
||||||
&UsersRemoveCommand,
|
UsersRemoveCommand,
|
||||||
&UsersResetCommand,
|
UsersResetCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersAddCommand configures the command name, flags, and action.
|
// UsersAddCommand configures the command name, flags, and action.
|
||||||
var UsersAddCommand = cli.Command{
|
var UsersAddCommand = &cli.Command{
|
||||||
Name: "add",
|
Name: "add",
|
||||||
Usage: "Creates a new user account",
|
Usage: "Creates a new user account",
|
||||||
ArgsUsage: "[username]",
|
ArgsUsage: "[username]",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersLegacyCommand configures the command name, flags, and action.
|
// UsersLegacyCommand configures the command name, flags, and action.
|
||||||
var UsersLegacyCommand = cli.Command{
|
var UsersLegacyCommand = &cli.Command{
|
||||||
Name: "legacy",
|
Name: "legacy",
|
||||||
Usage: "Lists legacy user accounts",
|
Usage: "Lists legacy user accounts",
|
||||||
ArgsUsage: "[search]",
|
ArgsUsage: "[search]",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersListCommand configures the command name, flags, and action.
|
// UsersListCommand configures the command name, flags, and action.
|
||||||
var UsersListCommand = cli.Command{
|
var UsersListCommand = &cli.Command{
|
||||||
Name: "ls",
|
Name: "ls",
|
||||||
Usage: "Lists registered user accounts",
|
Usage: "Lists registered user accounts",
|
||||||
Flags: append(report.CliFlags, CountFlag, UsersLoginFlag, UsersCreatedFlag, UsersDeletedFlag),
|
Flags: append(report.CliFlags, CountFlag, UsersLoginFlag, UsersCreatedFlag, UsersDeletedFlag),
|
||||||
|
|||||||
@@ -1,27 +1,15 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime/debug"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/photoprism/photoprism/pkg/capture"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUsersListCommand(t *testing.T) {
|
func TestUsersListCommand(t *testing.T) {
|
||||||
t.Run("All", func(t *testing.T) {
|
t.Run("All", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--login", "--created", "--deleted", "-n", "100", "--md"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "--login", "--created", "--deleted", "-n", "100", "--md"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -32,16 +20,8 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("LastLogin", func(t *testing.T) {
|
t.Run("LastLogin", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "-l", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "-l", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -53,16 +33,8 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("Created", func(t *testing.T) {
|
t.Run("Created", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "-a", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "-a", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -74,16 +46,8 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("Deleted", func(t *testing.T) {
|
t.Run("Deleted", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "-r", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "-r", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -95,16 +59,8 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "visitor")
|
assert.NotContains(t, output, "visitor")
|
||||||
})
|
})
|
||||||
t.Run("CSV", func(t *testing.T) {
|
t.Run("CSV", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--csv", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "--csv", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -116,16 +72,8 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.NotContains(t, output, "alice")
|
assert.NotContains(t, output, "alice")
|
||||||
})
|
})
|
||||||
t.Run("NoResult", func(t *testing.T) {
|
t.Run("NoResult", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "notexisting"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "notexisting"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
@@ -133,43 +81,20 @@ func TestUsersListCommand(t *testing.T) {
|
|||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
})
|
})
|
||||||
t.Run("OneResult", func(t *testing.T) {
|
t.Run("OneResult", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--count=1", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "--count=1", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check result.
|
// Check result.
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotEmpty(t, output)
|
assert.NotEmpty(t, output)
|
||||||
})
|
})
|
||||||
t.Run("InvalidFlag", func(t *testing.T) {
|
t.Run("InvalidFlag", func(t *testing.T) {
|
||||||
var err error
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
err = fmt.Errorf("error: %s \nstack: %s", r, debug.Stack())
|
|
||||||
assert.Error(t, err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Create test context with flags and arguments.
|
|
||||||
args := []string{"ls", "--xyz", "friend"}
|
|
||||||
ctx := NewTestContext(args)
|
|
||||||
|
|
||||||
// Run command with test context.
|
// Run command with test context.
|
||||||
output := capture.Output(func() {
|
output, err := RunWithTestContext(UsersListCommand, []string{"ls", "--xyz", "friend"})
|
||||||
err = UsersListCommand.Run(ctx, args...)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check command output for plausibility.
|
// Check command output for plausibility.
|
||||||
// t.Logf(output)
|
// t.Logf(output)
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Empty(t, output)
|
assert.Empty(t, output)
|
||||||
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersModCommand configures the command name, flags, and action.
|
// UsersModCommand configures the command name, flags, and action.
|
||||||
var UsersModCommand = cli.Command{
|
var UsersModCommand = &cli.Command{
|
||||||
Name: "mod",
|
Name: "mod",
|
||||||
Usage: "Changes user account settings",
|
Usage: "Changes user account settings",
|
||||||
ArgsUsage: "[username]",
|
ArgsUsage: "[username]",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersRemoveCommand configures the command name, flags, and action.
|
// UsersRemoveCommand configures the command name, flags, and action.
|
||||||
var UsersRemoveCommand = cli.Command{
|
var UsersRemoveCommand = &cli.Command{
|
||||||
Name: "rm",
|
Name: "rm",
|
||||||
Usage: "Deletes a registered user account",
|
Usage: "Deletes a registered user account",
|
||||||
ArgsUsage: "[username]",
|
ArgsUsage: "[username]",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
const UsersResetDescription = "This command recreates the session and user management database tables so that they are compatible with the current version. Should you experience login problems, for example after an upgrade from an earlier version or a development preview, we recommend that you first try the \"photoprism auth reset --yes\" command to see if it solves the issue. Note that any client access tokens and app passwords that users may have created are also deleted and must be recreated."
|
const UsersResetDescription = "This command recreates the session and user management database tables so that they are compatible with the current version. Should you experience login problems, for example after an upgrade from an earlier version or a development preview, we recommend that you first try the \"photoprism auth reset --yes\" command to see if it solves the issue. Note that any client access tokens and app passwords that users may have created are also deleted and must be recreated."
|
||||||
|
|
||||||
// UsersResetCommand configures the command name, flags, and action.
|
// UsersResetCommand configures the command name, flags, and action.
|
||||||
var UsersResetCommand = cli.Command{
|
var UsersResetCommand = &cli.Command{
|
||||||
Name: "reset",
|
Name: "reset",
|
||||||
Usage: "Removes all registered user accounts",
|
Usage: "Removes all registered user accounts",
|
||||||
Description: UsersResetDescription,
|
Description: UsersResetDescription,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// UsersShowCommand configures the command name, flags, and action.
|
// UsersShowCommand configures the command name, flags, and action.
|
||||||
var UsersShowCommand = cli.Command{
|
var UsersShowCommand = &cli.Command{
|
||||||
Name: "show",
|
Name: "show",
|
||||||
Usage: "Shows detailed account information",
|
Usage: "Shows detailed account information",
|
||||||
ArgsUsage: "[username]",
|
ArgsUsage: "[username]",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VersionCommand configures the "photoprism version" command.
|
// VersionCommand configures the "photoprism version" command.
|
||||||
var VersionCommand = cli.Command{
|
var VersionCommand = &cli.Command{
|
||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "Shows version information",
|
Usage: "Shows version information",
|
||||||
Action: versionAction,
|
Action: versionAction,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func TestCliFlag_Skip(t *testing.T) {
|
|||||||
Flag: &cli.StringFlag{
|
Flag: &cli.StringFlag{
|
||||||
Name: "with-tags",
|
Name: "with-tags",
|
||||||
Usage: "`STRING`",
|
Usage: "`STRING`",
|
||||||
EnvVars: []string{"PHOTOPRISM_WITH_TAGS"},
|
EnvVars: EnvVars("WITH_TAGS"),
|
||||||
},
|
},
|
||||||
Tags: []string{"foo", "bar"},
|
Tags: []string{"foo", "bar"},
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ func TestCliFlag_Skip(t *testing.T) {
|
|||||||
Flag: &cli.StringFlag{
|
Flag: &cli.StringFlag{
|
||||||
Name: "no-tags",
|
Name: "no-tags",
|
||||||
Usage: "`STRING`",
|
Usage: "`STRING`",
|
||||||
EnvVars: []string{"PHOTOPRISM_NO_TAGS"},
|
EnvVars: EnvVars("NO_TAGS"),
|
||||||
},
|
},
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,58 @@ func TestCliFlag_Skip(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCliFlag_EnvVars(t *testing.T) {
|
||||||
|
t.Run("None", func(t *testing.T) {
|
||||||
|
testFlag := CliFlag{
|
||||||
|
Flag: &cli.StringFlag{
|
||||||
|
Name: "test",
|
||||||
|
Usage: "`STRING`",
|
||||||
|
EnvVars: nil,
|
||||||
|
},
|
||||||
|
Tags: []string{"foo", "bar"},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "test", testFlag.Name())
|
||||||
|
assert.Equal(t, []string{"test"}, testFlag.Names())
|
||||||
|
assert.Equal(t, "test", testFlag.String())
|
||||||
|
assert.Equal(t, "", testFlag.EnvVar())
|
||||||
|
assert.Equal(t, []string{}, testFlag.EnvVars())
|
||||||
|
})
|
||||||
|
t.Run("One", func(t *testing.T) {
|
||||||
|
testFlag := CliFlag{
|
||||||
|
Flag: &cli.StringFlag{
|
||||||
|
Name: "test",
|
||||||
|
Usage: "`STRING`",
|
||||||
|
EnvVars: EnvVars("BAR_BAZ"),
|
||||||
|
},
|
||||||
|
Tags: []string{"foo", "bar"},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "test", testFlag.Name())
|
||||||
|
assert.Equal(t, []string{"test"}, testFlag.Names())
|
||||||
|
assert.Equal(t, "test", testFlag.String())
|
||||||
|
assert.Equal(t, "PHOTOPRISM_BAR_BAZ", testFlag.EnvVar())
|
||||||
|
assert.Equal(t, []string{"PHOTOPRISM_BAR_BAZ"}, testFlag.EnvVars())
|
||||||
|
})
|
||||||
|
t.Run("Multiple", func(t *testing.T) {
|
||||||
|
testFlag := CliFlag{
|
||||||
|
Flag: &cli.StringFlag{
|
||||||
|
Name: "test",
|
||||||
|
Aliases: []string{"t"},
|
||||||
|
Usage: "`STRING`",
|
||||||
|
EnvVars: EnvVars("FOO_1", "ORIGINALS_PATH"),
|
||||||
|
},
|
||||||
|
Tags: []string{"foo", "bar"},
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "test", testFlag.Name())
|
||||||
|
assert.Equal(t, []string{"test", "t"}, testFlag.Names())
|
||||||
|
assert.Equal(t, "test, t", testFlag.String())
|
||||||
|
assert.Equal(t, "PHOTOPRISM_FOO_1, PHOTOPRISM_ORIGINALS_PATH", testFlag.EnvVar())
|
||||||
|
assert.Equal(t, []string{"PHOTOPRISM_FOO_1", "PHOTOPRISM_ORIGINALS_PATH"}, testFlag.EnvVars())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestCliFlag_Hidden(t *testing.T) {
|
func TestCliFlag_Hidden(t *testing.T) {
|
||||||
hidden := CliFlag{
|
hidden := CliFlag{
|
||||||
Flag: &cli.StringFlag{
|
Flag: &cli.StringFlag{
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ func TestEnvVar(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEnvVars(t *testing.T) {
|
||||||
|
t.Run("None", func(t *testing.T) {
|
||||||
|
assert.Equal(t, []string{}, EnvVars())
|
||||||
|
})
|
||||||
|
t.Run("One", func(t *testing.T) {
|
||||||
|
assert.Equal(t, []string{"PHOTOPRISM_TEST"}, EnvVars(EnvTest))
|
||||||
|
})
|
||||||
|
t.Run("Multiple", func(t *testing.T) {
|
||||||
|
assert.Equal(t, []string{"PHOTOPRISM_FOO", "PHOTOPRISM_BAR", "PHOTOPRISM_BAZ_PATH"}, EnvVars("foo", "Bar", "BAZ_Path"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestEnv(t *testing.T) {
|
func TestEnv(t *testing.T) {
|
||||||
t.Run("True", func(t *testing.T) {
|
t.Run("True", func(t *testing.T) {
|
||||||
assert.True(t, Env(EnvTest))
|
assert.True(t, Env(EnvTest))
|
||||||
|
|||||||
Reference in New Issue
Block a user