Skip to content
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

test: add tunnel tests #2535

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

test: add tunnel tests #2535

wants to merge 1 commit into from

Conversation

phillebaba
Copy link
Member

@phillebaba phillebaba commented May 22, 2024

Description

Adds tests to cluster tunnel.

Related Issue

Relates to #2512

Checklist before merging

@phillebaba phillebaba requested review from dgershman and a team as code owners May 22, 2024 16:32
@phillebaba phillebaba marked this pull request as draft May 22, 2024 16:32
Copy link

netlify bot commented May 22, 2024

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit e3d2b74
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/664f173e8084d20008fc6347

@phillebaba
Copy link
Member Author

The tunnel connect function is currently too difficult to test. It will require some refactoring to split out the logic from the functionality to increase code coverage.

Name: "wrong-label",
Namespace: "",
Labels: map[string]string{
config.ZarfConnectLabelName: "wrong",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these error?

Comment on lines +69 to +75
ti, err := c.checkForZarfConnectLabel(ctx, "good")
require.NoError(t, err)
require.Equal(t, k8s.SvcResource, ti.resourceType)
require.Equal(t, "good-service", ti.resourceName)
require.Equal(t, "good-namespace", ti.namespace)
require.Equal(t, 9090, ti.remotePort)
require.Equal(t, "foobar", ti.urlSuffix)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this test primarily covers the happy path. I noticed the missing-label and wrong-label test cases, and I assume you would like to test those error paths as well.

I think we can iterate over the svcs and pass in svc.Name as an argument to checkForZarfConnectLabel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants