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

Move golden files below testdata/golden #232

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

adombeck
Copy link
Contributor

We used to store golden files in:

testdata/TopLevelTestName/golden/SubTestName

We now store them in:

testdata/golden/TopLevelTestName/SubTestName

That allows to easily copy/paste the full test name (top-level test name + subtest name) into a go test --run command.

@adombeck adombeck marked this pull request as ready for review November 19, 2024 10:55
@adombeck adombeck requested a review from a team as a code owner November 19, 2024 10:55
Copy link
Member

@denisonbarbosa denisonbarbosa left a comment

Choose a reason for hiding this comment

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

Regarding the changes, I have some comments but nothing big.

However, I do have 2 observations:

  1. Did you try reupdating the golden files to check if everything is ok? (I'm assuming you did, but it doesn't hurt to ask).

  2. We need to maintain consistency between our projects. If we agree on this new structure, this also implies applying these changes to authd, adsys, WSL and so on.

@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/ubuntu/authd-oidc-brokers/internal/broker"
"github.com/ubuntu/authd-oidc-brokers/internal/broker/authmodes"
"github.com/ubuntu/authd-oidc-brokers/internal/golden"
Copy link
Member

Choose a reason for hiding this comment

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

I can see the appeal here, but can you make it a subpackage of testutils? I don't think this belongs solely on internal/. This way, we can still relate to it as golden.CheckOrUpdate, but at least it's organized better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// GoldenOption is a supported option reference to change the golden files comparison.
type GoldenOption func(*goldenOptions)
// Option is a supported option reference to change the golden files comparison.
type Option func(*goldenOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Probably rename the goldenOptions type to options also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it to config to avoid name collisions

Comment on lines 368 to 371
err = f.Close()
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

👀 (you already know my comment...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@adombeck adombeck force-pushed the move-golden-files branch 2 times, most recently from 4539434 to 93dd088 Compare November 19, 2024 13:32
We used to store golden files in:

    testdata/TopLevelTestName/golden/SubTestName

We now store them in:

    testdata/golden/TopLevelTestName/SubTestName

That allows to easily copy/paste the full test name (top-level test name
+ subtest name) into a `go test --run` command.
The package name is already "golden", so we don't have to mention it
again in the exported names.
Avoid duplicating the package name in the struct name but also avoid
using the name "options" again which is already used as a parameter name
and local variable name in this package.
@adombeck
Copy link
Contributor Author

Did you try reupdating the golden files to check if everything is ok? (I'm assuming you did, but it doesn't hurt to ask).

Yes, all the golden files are updated.

We need to maintain consistency between our projects. If we agree on this new structure, this also implies applying these changes to authd, adsys, WSL and so on.

Right. My proposal is to change the structure for the reason mentioned above. If you or @didrocks (should I tag anyone else?) see any problems with that, I can split off the other changes into a separate PR. If I understood @didrocks correctly during the standup, he also prefers this directory structure.

@didrocks
Copy link
Member

Right. My proposal is to change the structure for the reason mentioned #232 (comment). If you or @didrocks (should I tag anyone else?) see any problems with that, I can split off the other changes into a separate PR. If I understood @didrocks correctly during the standup, he also prefers this directory structure.

Yeah, I think that ought to be 2 PRs, as we discussed in the HO, but that’s ok now. Just ensure there is a Jira card created on moving most of testutils/ (including this subpackage) to its own repo and list all the projects to move to it. That will make ofc backport harder in the futures when we can’t land the whole content, but that’s ok for now.

@adombeck
Copy link
Contributor Author

adombeck commented Nov 20, 2024

Just ensure there is a Jira card created on moving most of testutils/ (including this subpackage) to its own repo and list all the projects to move to it.

Tracked in UDENG-5363

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.

3 participants