• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chideat / valkey-operator / 15179145348

22 May 2025 05:49AM UTC coverage: 19.384% (+9.1%) from 10.284%
15179145348

Pull #18

github

chideat
chore: added unit test debug
Pull Request #18: chore: added more unit tests

174 of 315 new or added lines in 35 files covered. (55.24%)

7 existing lines in 2 files now uncovered.

3864 of 19934 relevant lines covered (19.38%)

0.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/api/core/validation/validation.go
1
/*
2
Copyright 2024 chideat.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package validation
18

19
import (
20
        "fmt"
21
        "slices"
22

23
        "github.com/chideat/valkey-operator/api/core"
24
        "github.com/chideat/valkey-operator/api/core/helper"
25
        corev1 "k8s.io/api/core/v1"
26
        "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
27
)
28

29
// ValidateInstanceAccess validates the instance access.
30
func ValidateInstanceAccess(acc *core.InstanceAccess, nodeCount int, warns *admission.Warnings) error {
1✔
31
        if acc == nil || acc.ServiceType == "" {
2✔
32
                return nil
1✔
33
        }
1✔
34

35
        if !slices.Contains([]corev1.ServiceType{
1✔
36
                corev1.ServiceTypeClusterIP,
1✔
37
                corev1.ServiceTypeNodePort,
1✔
38
                corev1.ServiceTypeLoadBalancer,
1✔
39
        }, acc.ServiceType) {
2✔
40
                return fmt.Errorf("unsupported service type: %s", acc.ServiceType)
1✔
41
        }
1✔
42

43
        if acc.ServiceType == corev1.ServiceTypeNodePort {
2✔
44
                if acc.Ports != "" {
2✔
45
                        ports, err := helper.ParsePorts(acc.Ports)
1✔
46
                        if err != nil {
1✔
NEW
47
                                return fmt.Errorf("failed to parse nodeports: %v", err)
×
48
                        }
×
49
                        if nodeCount != len(ports) {
2✔
50
                                return fmt.Errorf("expected %d nodes, but got %d ports to assign", nodeCount, len(ports))
1✔
51
                        }
1✔
52
                }
53
        }
54
        return nil
1✔
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc