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