propagate test cache dir in cli integration tests (#634)
This commit is contained in:
parent
e8e4bf0914
commit
99908b914d
@ -57,7 +57,7 @@ func CorsoCommand() *cobra.Command {
|
||||
func BuildCommandTree(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolP("version", "v", version, "current version info")
|
||||
cmd.PersistentPostRunE = config.InitFunc()
|
||||
config.AddConfigFileFlag(cmd)
|
||||
config.AddConfigFlags(cmd)
|
||||
print.AddOutputFlag(cmd)
|
||||
logger.AddLogLevelFlag(cmd)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ const (
|
||||
var configFilePath string
|
||||
|
||||
// adds the persistent flag --config-file to the provided command.
|
||||
func AddConfigFileFlag(cmd *cobra.Command) {
|
||||
func AddConfigFlags(cmd *cobra.Command) {
|
||||
fs := cmd.PersistentFlags()
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
|
||||
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
@ -80,6 +81,13 @@ func configureStorage(
|
||||
cCfg := storage.CommonConfig{
|
||||
Corso: corso,
|
||||
}
|
||||
// the following is a hack purely for integration testing.
|
||||
// the value is not required, and if empty, kopia will default
|
||||
// to its routine behavior
|
||||
if t, ok := vpr.Get("corso-testing").(bool); t && ok {
|
||||
dir, _ := filepath.Split(vpr.ConfigFileUsed())
|
||||
cCfg.KopiaCfgDir = dir
|
||||
}
|
||||
|
||||
// ensure required properties are present
|
||||
if err := utils.RequireProps(map[string]string{
|
||||
|
||||
@ -143,6 +143,7 @@ func MakeTempTestConfigClone(t *testing.T, overrides map[string]string) (*viper.
|
||||
vpr.AddConfigPath(tDir)
|
||||
vpr.SetConfigType(strings.TrimPrefix(ext, "."))
|
||||
vpr.SetConfigName(strings.TrimSuffix(fName, ext))
|
||||
vpr.Set("corso-testing", true)
|
||||
|
||||
for k, v := range cfg {
|
||||
vpr.Set(k, v)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user