Skip to content

Commit

Permalink
fix: add tests
Browse files Browse the repository at this point in the history
Signed-off-by: laurentiusoica <[email protected]>
  • Loading branch information
laurentiusoica committed Jun 17, 2024
1 parent fa71834 commit ed8dcbe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
35 changes: 35 additions & 0 deletions k8sutils/redis-sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/go-logr/logr"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/yaml"
Expand Down Expand Up @@ -175,6 +176,23 @@ func Test_generateRedisSentinelContainerParams(t *testing.T) {
Value: "custom_value_2",
},
},
AdditionalVolume: []v1.Volume{
{
Name: "redis-config",
VolumeSource: corev1.VolumeSource{
EmptyDir: &v1.EmptyDirVolumeSource{},
},
},
},
AdditionalMountPath: []v1.VolumeMount{
{
Name: "redis-config",
ReadOnly: false,
MountPath: "/etc/redis",
SubPath: "",
SubPathExpr: "",
},
},
}

data, err := os.ReadFile(path)
Expand Down Expand Up @@ -235,6 +253,23 @@ func Test_generateRedisSentinelInitContainerParams(t *testing.T) {
},
},
},
AdditionalVolume: []v1.Volume{
{
Name: "redis-config",
VolumeSource: corev1.VolumeSource{
EmptyDir: &v1.EmptyDirVolumeSource{},
},
},
},
AdditionalMountPath: []v1.VolumeMount{
{
Name: "redis-config",
ReadOnly: false,
MountPath: "/etc/redis",
SubPath: "",
SubPathExpr: "",
},
},
}

data, err := os.ReadFile(path)
Expand Down
7 changes: 7 additions & 0 deletions tests/testdata/redis-sentinel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,10 @@ spec:
secretKeyRef:
name: env-secrets
key: CLUSTER_NAMESPACE
volumeMount:
mountPath:
- mountPath: /etc/redis
name: redis-config
volume:
- emptyDir: {}
name: redis-config

Check failure on line 125 in tests/testdata/redis-sentinel.yaml

View workflow job for this annotation

GitHub Actions / Validate YAML

125:27 [new-line-at-end-of-file] no new line character at the end of file

0 comments on commit ed8dcbe

Please sign in to comment.