mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2026-04-06 13:49:18 +00:00
fix test
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
func TestGetType(t *testing.T) {
|
func TestGetType(t *testing.T) {
|
||||||
|
|
||||||
@@ -100,12 +108,28 @@ func TestLocationBackupWithMock(t *testing.T) {
|
|||||||
// Inject mock
|
// Inject mock
|
||||||
mock := &MockExecutor{
|
mock := &MockExecutor{
|
||||||
ExecuteResticFunc: func(options ExecuteOptions, args ...string) (int, string, error) {
|
ExecuteResticFunc: func(options ExecuteOptions, args ...string) (int, string, error) {
|
||||||
assertEqual(t, args[0], "backup")
|
assert.Equal(t, "backup", args[0])
|
||||||
return 0, "success", nil
|
return 0, "success", nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
DefaultExecutor = mock
|
DefaultExecutor = mock
|
||||||
|
|
||||||
|
// Setup dummy config
|
||||||
|
workDir := t.TempDir()
|
||||||
|
configFile := path.Join(workDir, ".autorestic.yml")
|
||||||
|
err := os.WriteFile(configFile, []byte("version: 2"), 0644)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
viper.Reset()
|
||||||
|
viper.SetConfigFile(configFile)
|
||||||
|
viper.Set("version", 2)
|
||||||
|
// Register test-backend
|
||||||
|
viper.Set("backends.test-backend.type", "local")
|
||||||
|
viper.Set("backends.test-backend.path", workDir)
|
||||||
|
|
||||||
|
config = nil
|
||||||
|
once = sync.Once{}
|
||||||
|
|
||||||
loc := Location{
|
loc := Location{
|
||||||
name: "test-location",
|
name: "test-location",
|
||||||
To: []string{"test-backend"},
|
To: []string{"test-backend"},
|
||||||
|
|||||||
Reference in New Issue
Block a user