Auth: Add tests for "photoprism auth ls" terminal command #808

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2024-01-18 11:13:10 +01:00
parent f08ef59245
commit 2ce272d60e
4 changed files with 131 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package commands
import (
"flag"
"os"
"testing"
@@ -28,3 +29,27 @@ func TestMain(m *testing.M) {
os.Exit(code)
}
// NewTestContext creates a new CLI test context with the flags and arguments provided.
func NewTestContext(args []string) *cli.Context {
// Create new command-line app.
app := cli.NewApp()
app.Usage = "PhotoPrism®"
app.Version = "test"
app.Copyright = "(c) 2018-2024 PhotoPrism UG. All rights reserved."
app.EnableBashCompletion = true
app.Flags = config.Flags.Cli()
app.Metadata = map[string]interface{}{
"Name": "PhotoPrism",
"About": "PhotoPrism®",
"Edition": "ce",
"Version": "test",
}
// Parse command arguments.
flags := flag.NewFlagSet("test", 0)
LogErr(flags.Parse(args))
// Create and return new context.
return cli.NewContext(app, flags, nil)
}