Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender committed Dec 6, 2024
1 parent 120014e commit 5e55aad
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions internal/controller/common/kube/assemblers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package kube
import (
"testing"

"github.com/chia-network/chia-operator/internal/controller/common/consts"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"

"github.com/chia-network/chia-operator/internal/controller/common/consts"

"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -101,19 +103,27 @@ func TestAssembleCommonService_Full(t *testing.T) {
Selector: map[string]string{
"app.kubernetes.io/name": "test",
},
SessionAffinity: corev1.ServiceAffinityClientIP,
SessionAffinityConfig: &corev1.SessionAffinityConfig{
ClientIP: &corev1.ClientIPConfig{
TimeoutSeconds: ptr.To(int32(300)),
},
},
},
}
actual := AssembleCommonService(AssembleCommonServiceInputs{
Name: expected.ObjectMeta.Name,
Namespace: expected.ObjectMeta.Namespace,
Labels: expected.ObjectMeta.Labels,
Annotations: expected.ObjectMeta.Annotations,
OwnerReference: expected.ObjectMeta.OwnerReferences,
Ports: expected.Spec.Ports,
SelectorLabels: expected.Spec.Selector,
ServiceType: &expected.Spec.Type,
IPFamilyPolicy: expected.Spec.IPFamilyPolicy,
IPFamilies: &expected.Spec.IPFamilies,
Name: expected.ObjectMeta.Name,
Namespace: expected.ObjectMeta.Namespace,
Labels: expected.ObjectMeta.Labels,
Annotations: expected.ObjectMeta.Annotations,
OwnerReference: expected.ObjectMeta.OwnerReferences,
Ports: expected.Spec.Ports,
SelectorLabels: expected.Spec.Selector,
ServiceType: &expected.Spec.Type,
IPFamilyPolicy: expected.Spec.IPFamilyPolicy,
IPFamilies: &expected.Spec.IPFamilies,
SessionAffinity: &expected.Spec.SessionAffinity,
SessionAffinityConfig: expected.Spec.SessionAffinityConfig,
})
require.Equal(t, expected, actual)
}
Expand Down

0 comments on commit 5e55aad

Please sign in to comment.