mirror of
https://github.com/rclone/rclone
synced 2024-11-26 04:07:22 +01:00
46078d391f
Before this change the config file needed to be explicitly reloaded. This coupled the config file implementation with the backends needlessly. This change stats the config file to see if it needs to be reloaded on every config file operation. This allows us to remove calls to - config.SaveConfig - config.GetFresh Which now makes the the only needed interface to the config file be that provided by configmap.Map when rclone is not being configured. This also adds tests for configfile
30 lines
752 B
Go
30 lines
752 B
Go
// These are in an external package because we need to import configfile
|
|
|
|
package config_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/rclone/rclone/fs/config"
|
|
"github.com/rclone/rclone/fs/config/configfile"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestConfigLoad(t *testing.T) {
|
|
oldConfigPath := config.ConfigPath
|
|
config.ConfigPath = "./testdata/plain.conf"
|
|
defer func() {
|
|
config.ConfigPath = oldConfigPath
|
|
}()
|
|
config.ClearConfigPassword()
|
|
configfile.LoadConfig(context.Background())
|
|
sections := config.Data.GetSectionList()
|
|
var expect = []string{"RCLONE_ENCRYPT_V0", "nounc", "unc"}
|
|
assert.Equal(t, expect, sections)
|
|
|
|
keys := config.Data.GetKeyList("nounc")
|
|
expect = []string{"type", "nounc"}
|
|
assert.Equal(t, expect, keys)
|
|
}
|