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 (
|
2020-11-06 00:59:59 +08:00
|
|
|
"context"
|
2016-02-16 23:25:27 +08:00
|
|
|
"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-03-10 23:40:34 +08:00
|
|
|
oldConfigPath := config.ConfigPath
|
|
|
|
config.ConfigPath = "./testdata/plain.conf"
|
2016-03-01 05:43:37 +08:00
|
|
|
defer func() {
|
2021-03-10 23:40:34 +08:00
|
|
|
config.ConfigPath = oldConfigPath
|
2016-03-01 05:43:37 +08:00
|
|
|
}()
|
2021-03-10 23:40:34 +08:00
|
|
|
config.ClearConfigPassword()
|
|
|
|
configfile.LoadConfig(context.Background())
|
|
|
|
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-03-10 23:40:34 +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
|
|
|
}
|