forked from vrischmann/envconfig
-
Notifications
You must be signed in to change notification settings - Fork 2
/
keys_test.go
62 lines (50 loc) · 1.56 KB
/
keys_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package envconfig
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestMakeAllPossibleKeys(t *testing.T) {
fieldName := "CassandraSslCert"
keys := makeAllPossibleKeys(&context{
name: fieldName,
})
require.Equal(t, 4, len(keys))
require.Equal(t, "CASSANDRASSLCERT", keys[0])
require.Equal(t, "CASSANDRA_SSL_CERT", keys[1])
require.Equal(t, "cassandra_ssl_cert", keys[2])
require.Equal(t, "cassandrasslcert", keys[3])
fieldName = "CassandraSSLCert"
keys = makeAllPossibleKeys(&context{
name: fieldName,
})
require.Equal(t, 4, len(keys))
require.Equal(t, "CASSANDRASSLCERT", keys[0])
require.Equal(t, "CASSANDRA_SSL_CERT", keys[1])
require.Equal(t, "cassandra_ssl_cert", keys[2])
require.Equal(t, "cassandrasslcert", keys[3])
fieldName = "Cassandra.SslCert"
keys = makeAllPossibleKeys(&context{
name: fieldName,
})
require.Equal(t, 4, len(keys))
require.Equal(t, "CASSANDRA_SSLCERT", keys[0])
require.Equal(t, "CASSANDRA_SSL_CERT", keys[1])
require.Equal(t, "cassandra_ssl_cert", keys[2])
require.Equal(t, "cassandra_sslcert", keys[3])
fieldName = "Cassandra.SSLCert"
keys = makeAllPossibleKeys(&context{
name: fieldName,
})
require.Equal(t, 4, len(keys))
require.Equal(t, "CASSANDRA_SSLCERT", keys[0])
require.Equal(t, "CASSANDRA_SSL_CERT", keys[1])
require.Equal(t, "cassandra_ssl_cert", keys[2])
require.Equal(t, "cassandra_sslcert", keys[3])
fieldName = "Name"
keys = makeAllPossibleKeys(&context{
name: fieldName,
})
require.Equal(t, 2, len(keys))
require.Equal(t, "NAME", keys[0])
require.Equal(t, "name", keys[1])
}