mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Auth: Add tests for "photoprism auth ls" terminal command #808
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user