github.com/andrewseidl/viper@v0.0.0-20191228040610-757ecc9b7b3e/util_test.go (about) 1 // Copyright © 2016 Steve Francia <spf@spf13.com>. 2 // 3 // Use of this source code is governed by an MIT-style 4 // license that can be found in the LICENSE file. 5 6 // Viper is a application configuration system. 7 // It believes that applications can be configured a variety of ways 8 // via flags, ENVIRONMENT variables, configuration files retrieved 9 // from the file system, or a remote key/value store. 10 11 package viper 12 13 import ( 14 "reflect" 15 "testing" 16 ) 17 18 func TestCopyAndInsensitiviseMap(t *testing.T) { 19 20 var ( 21 given = map[string]interface{}{ 22 "Foo": 32, 23 "Bar": map[interface{}]interface { 24 }{ 25 "ABc": "A", 26 "cDE": "B"}, 27 } 28 expected = map[string]interface{}{ 29 "foo": 32, 30 "bar": map[string]interface { 31 }{ 32 "abc": "A", 33 "cde": "B"}, 34 } 35 ) 36 37 got := copyAndInsensitiviseMap(given) 38 39 if !reflect.DeepEqual(got, expected) { 40 t.Fatalf("Got %q\nexpected\n%q", got, expected) 41 } 42 43 if _, ok := given["foo"]; ok { 44 t.Fatal("Input map changed") 45 } 46 47 if _, ok := given["bar"]; ok { 48 t.Fatal("Input map changed") 49 } 50 51 m := given["Bar"].(map[interface{}]interface{}) 52 if _, ok := m["ABc"]; !ok { 53 t.Fatal("Input map changed") 54 } 55 }