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