Skip to content

feat: add test for overwriting replica values #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
Joe committed Nov 8, 2021
commit ad9e241a6ac233040322ffdfb94b0b03f5d84c5f
57 changes: 57 additions & 0 deletions tests/security_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,60 @@ func TestSecurityContext(t *testing.T) {
})
}
}

func TestPostgresValues(t *testing.T) {
t.Parallel()

chart, err := loader.LoadDir("..")
require.NoError(t, err, "loaded chart successfully")
exampleOpenShift, err := ReadValues("../examples/openshift/openshift.values.yaml")
require.NoError(t, err, "failed to OpenShift example values")

tests := []struct {
Name string
Values *CoderValues
Postgres *corev1.Postgres
}{
{
Name: "openshift",
Values: exampleOpenShift,
Postgres: &any{
Default: &any{
Resources: &any{
Requests: &any{
// Expect this to fail
CPU: "1m",
Memory: "33Mi",
},
},
},
},
},
}

for _, test := range tests {
test := test
t.Run(test.Name, func(t *testing.T) {
t.Parallel()

objs, err := RenderChart(chart, test.Values, nil, nil)
require.NoError(t, err, "failed to render chart")

// Find the coderd Deployment
var found bool
for _, obj := range objs {
deployment, ok := obj.(*appsv1.Deployment)
if ok && deployment.Name == "coderd" {
found = true

expected := test.Postgres
// TODO@jsjoeio not sure what to do here.
actual := deployment.Spec.Template.Spec.SecurityContext
require.Equal(t, expected, actual, "expected matching PodSecurityContext")
break
}
}
require.True(t, found, "expected coderd deployment in manifests")
})
}
}