@@ -34,35 +34,42 @@ func TestReplicationManager_getReplicaName(t *testing.T) {
3434 }
3535}
3636
37- func TestReplicationManager_getPodFQDN (t * testing.T ) {
38- rm := & ReplicationManager {}
39-
37+ func TestGetPodFQDN (t * testing.T ) {
4038 tests := []struct {
41- podName string
42- clusterName string
43- namespace string
44- expected string
39+ name string
40+ podName string
41+ cluster * memgraphv1alpha1. MemgraphCluster
42+ expected string
4543 }{
4644 {
47- "my-cluster-0" ,
48- "my-cluster" ,
49- "default" ,
50- "my-cluster-0.my-cluster-headless.default.svc.cluster.local" ,
45+ name : "default suffix" ,
46+ podName : "my-cluster-0" ,
47+ cluster : & memgraphv1alpha1.MemgraphCluster {
48+ ObjectMeta : metav1.ObjectMeta {Name : "my-cluster" , Namespace : "default" },
49+ },
50+ expected : "my-cluster-0.my-cluster-hl.default.svc.cluster.local" ,
5151 },
5252 {
53- "prod-db-1" ,
54- "prod-db" ,
55- "production" ,
56- "prod-db-1.prod-db-headless.production.svc.cluster.local" ,
53+ name : "custom suffix" ,
54+ podName : "prod-db-1" ,
55+ cluster : & memgraphv1alpha1.MemgraphCluster {
56+ ObjectMeta : metav1.ObjectMeta {Name : "prod-db" , Namespace : "production" },
57+ Spec : memgraphv1alpha1.MemgraphClusterSpec {
58+ ServiceNames : & memgraphv1alpha1.ServiceNamesSpec {
59+ HeadlessSuffix : "-headless" ,
60+ },
61+ },
62+ },
63+ expected : "prod-db-1.prod-db-headless.production.svc.cluster.local" ,
5764 },
5865 }
5966
6067 for _ , tt := range tests {
61- t .Run (tt .podName , func (t * testing.T ) {
62- result := rm . getPodFQDN (tt .podName , tt .clusterName , tt . namespace )
68+ t .Run (tt .name , func (t * testing.T ) {
69+ result := getPodFQDN (tt .podName , tt .cluster )
6370 if result != tt .expected {
64- t .Errorf ("getPodFQDN(%s, %s, %s ) = %s, want %s" ,
65- tt .podName , tt . clusterName , tt . namespace , result , tt .expected )
71+ t .Errorf ("getPodFQDN(%s, cluster ) = %s, want %s" ,
72+ tt .podName , result , tt .expected )
6673 }
6774 })
6875 }
0 commit comments