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

ctx: fix group+controlplane context code and add tests #462

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Apr 15, 2024

Follow-up of #455, doing what @tnthornton suggested in #455 (comment).

Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.com>
@sttts sttts force-pushed the sttts-ctx-kubeconfig-fixes-and-tests branch from 00ddca8 to cbdc775 Compare April 15, 2024 18:47
Copy link
Member

@tnthornton tnthornton left a comment

Choose a reason for hiding this comment

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

Thanks @sttts for all of the tests 🙇

I have a couple of nits, but nothing blocking.

t.Run(name, func(t *testing.T) {
g := &Group{name: tt.group}
conf, last, err := g.accept(tt.conf, profile.Profile{KubeContext: "profile"}, tt.preferred)
if diff := cmp.Diff(tt.wantErr, fmt.Sprintf("%v", err)); diff != "" {
Copy link
Member

Choose a reason for hiding this comment

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

nit - instead of converting to a string, we could do something like

if diff := cmp.Diff(tt.wantErr, err, test.EquateErrors())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's too strict. I know that Crossplane does it. But it checks the underlying type. IMO it is not what you want in most cases.

t.Run(name, func(t *testing.T) {
ctp := &ControlPlane{NamespacedName: tt.ctp}
conf, last, err := ctp.accept(tt.conf, profile.Profile{KubeContext: "profile"}, "https://ingress", []byte{1, 2, 3}, tt.preferred)
if diff := cmp.Diff(tt.wantErr, fmt.Sprintf("%v", err)); diff != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment for down here.

@sttts sttts merged commit c7fcb3b into upbound:main Apr 15, 2024
6 checks passed
@sttts sttts deleted the sttts-ctx-kubeconfig-fixes-and-tests branch April 15, 2024 20:29
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

2 participants