2021-03-12 00:20:31 +08:00
|
|
|
// These are in an external package because we need to import configfile
|
|
|
|
|
2021-03-10 23:40:34 +08:00
|
|
|
package config_test
|
2015-02-20 03:26:00 +08:00
|
|
|
|
2016-02-16 23:25:27 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
2016-06-30 00:59:31 +08:00
|
|
|
|
2021-03-10 23:40:34 +08:00
|
|
|
"github.com/rclone/rclone/fs/config"
|
|
|
|
"github.com/rclone/rclone/fs/config/configfile"
|
2016-06-30 00:59:31 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-02-16 23:25:27 +08:00
|
|
|
)
|
2015-02-20 03:26:00 +08:00
|
|
|
|
2016-02-16 23:25:27 +08:00
|
|
|
func TestConfigLoad(t *testing.T) {
|
2021-04-08 23:49:47 +08:00
|
|
|
oldConfigPath := config.GetConfigPath()
|
|
|
|
assert.NoError(t, config.SetConfigPath("./testdata/plain.conf"))
|
2016-03-01 05:43:37 +08:00
|
|
|
defer func() {
|
2021-04-08 23:49:47 +08:00
|
|
|
assert.NoError(t, config.SetConfigPath(oldConfigPath))
|
2016-03-01 05:43:37 +08:00
|
|
|
}()
|
2021-03-10 23:40:34 +08:00
|
|
|
config.ClearConfigPassword()
|
2021-04-27 05:37:49 +08:00
|
|
|
configfile.Install()
|
|
|
|
sections := config.Data().GetSectionList()
|
2016-02-16 23:25:27 +08:00
|
|
|
var expect = []string{"RCLONE_ENCRYPT_V0", "nounc", "unc"}
|
2016-06-30 00:59:31 +08:00
|
|
|
assert.Equal(t, expect, sections)
|
2016-02-16 23:25:27 +08:00
|
|
|
|
2021-04-27 05:37:49 +08:00
|
|
|
keys := config.Data().GetKeyList("nounc")
|
2016-02-16 23:25:27 +08:00
|
|
|
expect = []string{"type", "nounc"}
|
2016-06-30 00:59:31 +08:00
|
|
|
assert.Equal(t, expect, keys)
|
2016-02-16 23:25:27 +08:00
|
|
|
}
|