MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / newFakePooler

Function newFakePooler

internal/controller/suite_test.go:139–175  ·  view source on GitHub ↗
(k8sClient client.Client, cluster *apiv1.Cluster)

Source from the content-addressed store, hash-verified

137}
138
139func newFakePooler(k8sClient client.Client, cluster *apiv1.Cluster) *apiv1.Pooler {
140 pooler := &apiv1.Pooler{
141 ObjectMeta: metav1.ObjectMeta{
142 Name: "pooler-" + rand.String(10),
143 Namespace: cluster.Namespace,
144 Annotations: map[string]string{},
145 Labels: map[string]string{},
146 },
147 Spec: apiv1.PoolerSpec{
148 Cluster: apiv1.LocalObjectReference{
149 Name: cluster.Name,
150 },
151 Type: "rw",
152 Instances: ptr.To(int32(1)),
153 PgBouncer: &apiv1.PgBouncerSpec{
154 PoolMode: apiv1.PgBouncerPoolModeSession,
155 },
156 },
157 Status: apiv1.PoolerStatus{
158 // Pre-populate the resolved image so unit tests that call
159 // updateDeployment directly (bypassing updatePoolerStatus) start from
160 // the same precondition as a fully reconciled Pooler.
161 Image: configuration.Current.PgbouncerImageName,
162 },
163 }
164
165 err := k8sClient.Create(context.Background(), pooler)
166 Expect(err).ToNot(HaveOccurred())
167
168 // upstream issue, go client cleans typemeta: https://github.com/kubernetes/client-go/issues/308
169 pooler.TypeMeta = metav1.TypeMeta{
170 Kind: apiv1.PoolerKind,
171 APIVersion: apiv1.SchemeGroupVersion.String(),
172 }
173
174 return pooler
175}
176
177func newFakeCNPGCluster(
178 k8sClient client.Client,

Calls 2

CreateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected