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

DENA-671: refactor: extracted test cases from func & split them into multiple scenarios #26

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

sbuliarca
Copy link
Contributor

This solves the //nolint:maintidx for the test func & adds more clarity to test groups

@sbuliarca sbuliarca requested a review from a team as a code owner October 25, 2024 15:02
Copy link

linear bot commented Oct 25, 2024

Comment on lines +746 to +751
res := make([]*helper.Issue, len(expected))
for i, exp := range expected {
exp.Rule = rule
res[i] = exp
}
return res
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this function both mutates an input (via exp.Rule = rule) and returns a separate output. I think it should either be pure, and just return the useful bits, or mutate its input and return nothing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Riight.. I didn't realise I get a pointer to the issue. Will address separate

Comment on lines 720 to 726
var allTests []topicConfigTestCase
allTests = append(allTests, replicationFactorTests...)
allTests = append(allTests, compressionTypeTests...)
allTests = append(allTests, cleanupPolicyTests...)
allTests = append(allTests, deletePolicyRetentionTimeTests...)
allTests = append(allTests, deletePolicyTieredStorageTests...)
allTests = append(allTests, goodConfigTests...)
Copy link
Contributor

Choose a reason for hiding this comment

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

random thought: I really like the iterators in Go 1.23 that would allow us to do this lazily (i.e. loop over all this sub-arrays without constructing a new one)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about this one... I think it's clearer what's happening like this.
I think in the implementing Seq func we'd still to iterate through each of these slices, or to unify them and then iterate, just like in here

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this one... I think it's clearer what's happening like this. I think in the implementing Seq func we'd still to iterate through each of these slices, or to unify them and then iterate, just like in here

Unless there w as a library for that 😉 https://pkg.go.dev/github.com/matthewhughes934/[email protected]/itertools#ChainSlices (not saying to use it, just something I had some fun playing around with recently)

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'll leave it like this, if you don't mind, as I don't want to introduce a dependency from a repo of some shady dude

* Validate tiered storage not enabled for compacted topics

* Validate local retention not defined for compacted topics

* Validate retention time not defined for compacted topics
@sbuliarca sbuliarca merged commit 1d5969a into main Oct 28, 2024
5 checks passed
@sbuliarca sbuliarca deleted the config-test-refactor branch October 28, 2024 10:49
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.

2 participants