MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / TestPod

Function TestPod

internal/pgadmin/reconcile_test.go:69–551  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestPod(t *testing.T) {
70 t.Parallel()
71
72 cluster := new(v1beta1.PostgresCluster)
73 config := new(corev1.ConfigMap)
74 pod := new(corev1.PodSpec)
75 pvc := new(corev1.PersistentVolumeClaim)
76
77 call := func() { Pod(cluster, config, pod, pvc) }
78
79 t.Run("Disabled", func(t *testing.T) {
80 before := pod.DeepCopy()
81 call()
82
83 // No change when pgAdmin is not requested in the spec.
84 assert.DeepEqual(t, before, pod)
85 })
86
87 t.Run("Defaults", func(t *testing.T) {
88 cluster.Spec.UserInterface = new(v1beta1.UserInterfaceSpec)
89 cluster.Spec.UserInterface.PGAdmin = new(v1beta1.PGAdminPodSpec)
90 cluster.Default()
91
92 call()
93
94 assert.Assert(t, cmp.MarshalMatches(pod, `
95containers:
96- command:
97 - bash
98 - -c
99 - |-
100 CRUNCHY_DIR=${CRUNCHY_DIR:-'/opt/crunchy'}
101 PGADMIN_DIR=/usr/lib/python3.6/site-packages/pgadmin4-web
102 APACHE_PIDFILE='/tmp/httpd.pid'
103 export PATH=$PATH:/usr/pgsql-*/bin
104
105 RED="\033[0;31m"
106 GREEN="\033[0;32m"
107 RESET="\033[0m"
108
109 function enable_debugging() {
110 if [[ ${CRUNCHY_DEBUG:-false} == "true" ]]
111 then
112 echo_info "Turning debugging on.."
113 export PS4='+(${BASH_SOURCE}:${LINENO})> ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
114 set -x
115 fi
116 }
117
118 function env_check_err() {
119 if [[ -z ${!1} ]]
120 then
121 echo_err "$1 environment variable is not set, aborting."
122 exit 1
123 fi
124 }
125
126 function echo_info() {

Callers

nothing calls this directly

Calls 4

MarshalMatchesFunction · 0.92
PodFunction · 0.70
DeepCopyMethod · 0.45
DefaultMethod · 0.45

Tested by

no test coverage detected