Files
narratio/internal/app/command_test_helpers_test.go

31 lines
1.0 KiB
Go

package app
import (
"context"
"io"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"go.maximumdirect.net/commandkit"
)
func executeForTest(args []string, stdout, stderr io.Writer) int {
return executeWithDependencies(args, stdout, stderr, commandDependencies{}, executePlan)
}
func executeWithPipelineExecutor(args []string, stdout, stderr io.Writer, executor pipelineExecutor) int {
return executeWithDependencies(args, stdout, stderr, commandDependencies{}, executor)
}
func executeWithDependencies(args []string, stdout, stderr io.Writer, deps commandDependencies, executor pipelineExecutor) int {
if deps.newObjectStore == nil {
deps.newObjectStore = func(context.Context, *config.Config) (storage.ObjectStore, error) { return &storage.FakeBackend{}, nil }
}
application, err := newApplication(deps, executor)
if err != nil {
panic(err)
}
return application.Execute(context.Background(), args, commandkit.Streams{Out: stdout, Err: stderr}).Status
}