@@ -14,118 +14,6 @@ import (
1414 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1515)
1616
17- func TestFetchKeyCommand (t * testing.T ) {
18- t .Run ("missing" , func (t * testing.T ) {
19- spec1 := v1beta1.PostgresClusterSpec {}
20- assert .Assert (t , FetchKeyCommand (& spec1 ) == "" )
21-
22- spec2 := v1beta1.PostgresClusterSpec {
23- Patroni : & v1beta1.PatroniSpec {},
24- }
25- assert .Assert (t , FetchKeyCommand (& spec2 ) == "" )
26-
27- spec3 := v1beta1.PostgresClusterSpec {
28- Patroni : & v1beta1.PatroniSpec {
29- DynamicConfiguration : map [string ]any {},
30- },
31- }
32- assert .Assert (t , FetchKeyCommand (& spec3 ) == "" )
33-
34- spec4 := v1beta1.PostgresClusterSpec {
35- Patroni : & v1beta1.PatroniSpec {
36- DynamicConfiguration : map [string ]any {
37- "postgresql" : map [string ]any {},
38- },
39- },
40- }
41- assert .Assert (t , FetchKeyCommand (& spec4 ) == "" )
42-
43- spec5 := v1beta1.PostgresClusterSpec {
44- Patroni : & v1beta1.PatroniSpec {
45- DynamicConfiguration : map [string ]any {
46- "postgresql" : map [string ]any {
47- "parameters" : map [string ]any {},
48- },
49- },
50- },
51- }
52- assert .Assert (t , FetchKeyCommand (& spec5 ) == "" )
53- })
54-
55- t .Run ("blank" , func (t * testing.T ) {
56- var spec1 v1beta1.PostgresClusterSpec
57- require .UnmarshalInto (t , & spec1 , `{
58- patroni: {
59- dynamicConfiguration: {
60- postgresql: {
61- parameters: {
62- encryption_key_command: "",
63- },
64- },
65- },
66- },
67- }` )
68- assert .Equal (t , "" , FetchKeyCommand (& spec1 ))
69-
70- var spec2 v1beta1.PostgresClusterSpec
71- require .UnmarshalInto (t , & spec2 , `{
72- config: {
73- parameters: {
74- encryption_key_command: "",
75- },
76- },
77- }` )
78- assert .Equal (t , "" , FetchKeyCommand (& spec2 ))
79- })
80-
81- t .Run ("exists" , func (t * testing.T ) {
82- var spec1 v1beta1.PostgresClusterSpec
83- require .UnmarshalInto (t , & spec1 , `{
84- patroni: {
85- dynamicConfiguration: {
86- postgresql: {
87- parameters: {
88- encryption_key_command: "echo mykey",
89- },
90- },
91- },
92- },
93- }` )
94- assert .Equal (t , "echo mykey" , FetchKeyCommand (& spec1 ))
95-
96- var spec2 v1beta1.PostgresClusterSpec
97- require .UnmarshalInto (t , & spec2 , `{
98- config: {
99- parameters: {
100- encryption_key_command: "cat somefile",
101- },
102- },
103- }` )
104- assert .Equal (t , "cat somefile" , FetchKeyCommand (& spec2 ))
105- })
106-
107- t .Run ("config.parameters takes precedence" , func (t * testing.T ) {
108- var spec v1beta1.PostgresClusterSpec
109- require .UnmarshalInto (t , & spec , `{
110- config: {
111- parameters: {
112- encryption_key_command: "cat somefile",
113- },
114- },
115- patroni: {
116- dynamicConfiguration: {
117- postgresql: {
118- parameters: {
119- encryption_key_command: "echo mykey",
120- },
121- },
122- },
123- },
124- }` )
125- assert .Equal (t , "cat somefile" , FetchKeyCommand (& spec ))
126- })
127- }
128-
12917func TestPGAdminContainerImage (t * testing.T ) {
13018 cluster := & v1beta1.PostgresCluster {}
13119
0 commit comments