in internal/testhelpers/testcases.go [45:74]
func (cc *TestCaseClient) CreateResource(ctx context.Context) (*cloudsqlapi.AuthProxyWorkload, error) {
const (
name = "instance1"
expectedConnStr = "proj:inst:db"
)
ns := cc.Namespace
err := cc.CreateOrPatchNamespace(ctx)
if err != nil {
return nil, fmt.Errorf("can't create namespace, %v", err)
}
key := types.NamespacedName{Name: name, Namespace: ns}
_, err = cc.CreateAuthProxyWorkload(ctx, key, "app", expectedConnStr, "Deployment")
if err != nil {
return nil, fmt.Errorf("unable to create auth proxy workload %v", err)
}
res, err := cc.GetAuthProxyWorkloadAfterReconcile(ctx, key)
if err != nil {
return nil, fmt.Errorf("unable to find entity after create %v", err)
}
if connStr := res.Spec.Instances[0].ConnectionString; connStr != expectedConnStr {
return nil, fmt.Errorf("was %v, wants %v, spec.cloudSqlInstance", connStr, expectedConnStr)
}
if wlstatus := GetConditionStatus(res.Status.Conditions, cloudsqlapi.ConditionUpToDate); wlstatus != metav1.ConditionTrue {
return nil, fmt.Errorf("was %v, wants %v, status.condition[up-to-date]", wlstatus, metav1.ConditionTrue)
}
return res, nil
}