Commit 6bd557eb authored by Martin Schurz's avatar Martin Schurz
Browse files

fix: add tests for annotations in Service

parent 4c53e578
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -22,23 +22,42 @@ func TestServiceTemplate_ServiceType(t *testing.T) {
		expectedType        string
		expectedPort        coreV1.ServicePort
		expectedErrorRegexp *regexp.Regexp
		ExpectedAnnotations map[string]string
	}{
		{
			name:         "defaults",
			expectedType: "ClusterIP",
			expectedPort: coreV1.ServicePort{Port: 5000, TargetPort: intstr.FromInt(5000), Protocol: "TCP", Name: "web"},
			ExpectedAnnotations: nil,
		},
		{
			name:         "with type NodePort but no nodePort value",
			values:       map[string]string{"service.type": "NodePort"},
			expectedType: "NodePort",
			expectedPort: coreV1.ServicePort{Port: 5000, TargetPort: intstr.FromInt(5000), NodePort: 0, Protocol: "TCP", Name: "web"},
			ExpectedAnnotations: nil,
		},
		{
			name:         "with type NodePort and nodePort set",
			values:       map[string]string{"service.type": "NodePort", "service.nodePort": "12345"},
			expectedType: "NodePort",
			expectedPort: coreV1.ServicePort{Port: 5000, TargetPort: intstr.FromInt(5000), NodePort: 12345, Protocol: "TCP", Name: "web"},
			ExpectedAnnotations: nil,
		},
		{
			name:         "with type NodePort and nodePort set",
			values:       map[string]string{
				"service.type": "NodePort",
				"service.nodePort": "12345",
				"service.annotations.key1": "value1",
				"service.annotations.key2": "value2",
			},
			expectedType: "NodePort",
			expectedPort: coreV1.ServicePort{Port: 5000, TargetPort: intstr.FromInt(5000), NodePort: 12345, Protocol: "TCP", Name: "web"},
			ExpectedAnnotations: map[string]string{
				"key1": "value1",
				"key2": "value2",
			},
		},
	}