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

Add Regal bundle to test cmd runner #197

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

kristiansvalland
Copy link
Collaborator

Also add e2e test to validate that the bundle is added correctly.

Fixes #196

Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

👏 What a nice first contribution. Thanks a lot!

t.Parallel()

stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, just a random thought -- I wonder if something like this would be useful for testing:

type panicWriter struct{}

func (*panicWriter) Write([]byte) (int, error) {
	panic("write unexpected")
}

It's like io.Discard just with a little more drama. https://play.golang.com/p/xCQlGZH2nUq

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would certainly reduce boilerplate in the test cases, at the cost of clarity in the error messages when the tests do fail.

In the current state we get "expected stderr %q, got %q", which I would appreciate to see myself if I did some changes that broke a test. This error message would likely point me in the right direction immediately.

Using this proposed construct, the test would only report "write unexpected" without any context. In this latter case, I would likely then start a debug session or add print calls to get going.

The importance of boilerplate vs error messages and preferred working style of course varies between developers, so this is only my personal thoughts on it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah you've made a good point there. Perhaps something that takes a *testing.T and fails accordingly would strike a middle ground... maybe some day 🙃

@anderseknert
Copy link
Member

This looks great! I’m on mobile but do I see it right that no checks are running for this PR? I wonder why that might be. I don’t see an option to “approve” of them either. @srenatus you know?

@srenatus
Copy link
Member

@anderseknert The build workflow's "on" is wonky, I think:

on:
  push:
    branches:
      - '**'
  workflow_dispatch:

This only matches branches on this repository and will thus not run for PRs from forks. OPA uses that

on: [pull_request]

Also, we don't have protection rules defined, it seems, so the checks aren't required by github either. Hence the PR got green without any tests run.

@srenatus srenatus mentioned this pull request Jul 11, 2023
Also add e2e test to validate that the bundle is added correctly.

Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
@anderseknert anderseknert merged commit 59d0682 into StyraInc:main Jul 11, 2023
1 check passed
@anderseknert
Copy link
Member

Thanks Kristian!

@kristiansvalland kristiansvalland deleted the regal-test-load-bundle branch July 12, 2023 06:39
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
* Add Regal bundle to test cmd runner

Also add e2e test to validate that the bundle is added correctly.

Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
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.

regal test reports "undefined function data.regal.result.fail"
3 participants