diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-06-21 10:30:20 -0400 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-06-21 16:30:20 +0200 |
commit | 07c785e294e70494ae6016d59749a71af3f74920 (patch) | |
tree | 9b5e8deb15a182aa6a890261bb77b2e6faebbaea /vendor/github.com/mattermost/viper/util_test.go | |
parent | 1f65f0e3d6d142b859f8dda52da99cb3d4a01c9c (diff) | |
download | chat-07c785e294e70494ae6016d59749a71af3f74920.tar.gz chat-07c785e294e70494ae6016d59749a71af3f74920.tar.bz2 chat-07c785e294e70494ae6016d59749a71af3f74920.zip |
MM-10730 Added support for empty environment variables to viper (#8973)
Diffstat (limited to 'vendor/github.com/mattermost/viper/util_test.go')
-rw-r--r-- | vendor/github.com/mattermost/viper/util_test.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/mattermost/viper/util_test.go b/vendor/github.com/mattermost/viper/util_test.go new file mode 100644 index 000000000..0af80bb63 --- /dev/null +++ b/vendor/github.com/mattermost/viper/util_test.go @@ -0,0 +1,54 @@ +// Copyright © 2016 Steve Francia <spf@spf13.com>. +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file. + +// Viper is a application configuration system. +// It believes that applications can be configured a variety of ways +// via flags, ENVIRONMENT variables, configuration files retrieved +// from the file system, or a remote key/value store. + +package viper + +import ( + "reflect" + "testing" +) + +func TestCopyAndInsensitiviseMap(t *testing.T) { + var ( + given = map[string]interface{}{ + "Foo": 32, + "Bar": map[interface{}]interface { + }{ + "ABc": "A", + "cDE": "B"}, + } + expected = map[string]interface{}{ + "foo": 32, + "bar": map[string]interface { + }{ + "abc": "A", + "cde": "B"}, + } + ) + + got := copyAndInsensitiviseMap(given) + + if !reflect.DeepEqual(got, expected) { + t.Fatalf("Got %q\nexpected\n%q", got, expected) + } + + if _, ok := given["foo"]; ok { + t.Fatal("Input map changed") + } + + if _, ok := given["bar"]; ok { + t.Fatal("Input map changed") + } + + m := given["Bar"].(map[interface{}]interface{}) + if _, ok := m["ABc"]; !ok { + t.Fatal("Input map changed") + } +} |