(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestInstancePod(t *testing.T) { |
| 111 | t.Parallel() |
| 112 | |
| 113 | cluster := new(v1beta1.PostgresCluster) |
| 114 | cluster.Default() |
| 115 | cluster.Name = "some-such" |
| 116 | cluster.Spec.PostgresVersion = 11 |
| 117 | cluster.Spec.Image = "image" |
| 118 | cluster.Spec.ImagePullPolicy = corev1.PullAlways |
| 119 | clusterConfigMap := new(corev1.ConfigMap) |
| 120 | clusterPodService := new(corev1.Service) |
| 121 | instanceCertificates := new(corev1.Secret) |
| 122 | instanceConfigMap := new(corev1.ConfigMap) |
| 123 | instanceSpec := new(v1beta1.PostgresInstanceSetSpec) |
| 124 | patroniLeaderService := new(corev1.Service) |
| 125 | template := new(corev1.PodTemplateSpec) |
| 126 | template.Spec.Containers = []corev1.Container{{Name: "database"}} |
| 127 | |
| 128 | call := func() error { |
| 129 | return InstancePod(context.Background(), |
| 130 | cluster, clusterConfigMap, clusterPodService, patroniLeaderService, |
| 131 | instanceSpec, instanceCertificates, instanceConfigMap, template) |
| 132 | } |
| 133 | |
| 134 | assert.NilError(t, call()) |
| 135 | |
| 136 | assert.DeepEqual(t, template.ObjectMeta, metav1.ObjectMeta{ |
| 137 | Labels: map[string]string{naming.LabelPatroni: "some-such-ha"}, |
| 138 | }) |
| 139 | |
| 140 | assert.Assert(t, cmp.MarshalMatches(template.Spec, ` |
| 141 | containers: |
| 142 | - command: |
| 143 | - sh |
| 144 | - -c |
| 145 | - -- |
| 146 | - PATH="/usr/lib/postgresql/11/bin:/usr/libexec/postgresql11:/usr/pgsql-11/bin${PATH+:${PATH}}" |
| 147 | && exec "$@" |
| 148 | - -- |
| 149 | - patroni |
| 150 | - /etc/patroni |
| 151 | env: |
| 152 | - name: PATRONI_NAME |
| 153 | valueFrom: |
| 154 | fieldRef: |
| 155 | apiVersion: v1 |
| 156 | fieldPath: metadata.name |
| 157 | - name: PATRONI_KUBERNETES_POD_IP |
| 158 | valueFrom: |
| 159 | fieldRef: |
| 160 | apiVersion: v1 |
| 161 | fieldPath: status.podIP |
| 162 | - name: PATRONI_KUBERNETES_PORTS |
| 163 | value: | |
| 164 | [] |
| 165 | - name: PATRONI_POSTGRESQL_CONNECT_ADDRESS |
| 166 | value: $(PATRONI_NAME).:5432 |
| 167 | - name: PATRONI_POSTGRESQL_LISTEN |
nothing calls this directly
no test coverage detected