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

tests: don't save version in snapshot #5

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Conversation

shepherdjerred
Copy link
Contributor

As versions update, these tests will start to fail.

@jmwoliver suggested that we could store the built distributions in this repository. I see a little bit of value in using the latest versions of these libraries to ensure that we continue to pull the correct metadata as they update, although that does lead to failures occurring.

@shepherdjerred shepherdjerred requested review from jmwoliver, a team and glin and removed request for a team November 6, 2023 21:34
parse_test.go Outdated
Comment on lines 357 to 358
if value, ok := copiedData[field]; ok {
values := lo.Map(value, func(item string, _ int) string {
return re.ReplaceAllString(item, "X")
})
copiedData[field] = values
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be easier to delete the fields from the map entirely?

Suggested change
if value, ok := copiedData[field]; ok {
values := lo.Map(value, func(item string, _ int) string {
return re.ReplaceAllString(item, "X")
})
copiedData[field] = values
}
if value, ok := copiedData[field]; ok {
delete(copiedData, field)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess your intent is to try to preserve the information? I'm not sure if it is useful and I think this could still break if the length of the version string changed from something like 1.2.3 to 1.2.3dev0. Or am I misunderstanding how it replaces?

Copy link
Contributor Author

@shepherdjerred shepherdjerred Nov 6, 2023

Choose a reason for hiding this comment

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

I was trying to prevent deleting anything since it reduces how effective these tests are, but you are right that this will cause issues for versions that change length.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we wanted to preserve that it is set to something, maybe we can just set it to the field name?

Suggested change
if value, ok := copiedData[field]; ok {
values := lo.Map(value, func(item string, _ int) string {
return re.ReplaceAllString(item, "X")
})
copiedData[field] = values
}
if _, ok := copiedData[field]; ok {
copiedData[field] = field
}

I'm not sure if that is any better than just deleting the fields that change though. I'm good with whichever you think is best!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what we did before. I think you're right that it's better.

- cron: "0 0 * * *"
- cron: "0 0 1 * *" # run on the first of each month
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should make test failures due to dependency updates less annoying.

Copy link
Collaborator

@jmwoliver jmwoliver left a comment

Choose a reason for hiding this comment

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

Looks good! Just had one last comment.

Comment on lines +354 to +357
values := lo.Map(value, func(_ string, _ int) string {
return fmt.Sprintf("%s exists", field)
})
copiedData[field] = values
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be simplified back to what it was?

Suggested change
values := lo.Map(value, func(_ string, _ int) string {
return fmt.Sprintf("%s exists", field)
})
copiedData[field] = values
copiedData[field] = []string{fmt.Sprintf("%s exists", field)}

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 don't think so. It's unlikely, but since the input is a list of strings we don't want to assume the length. For example if we somehow send a list of versions or checksums we'd want to know.

@shepherdjerred shepherdjerred merged commit ca38eb1 into main Nov 6, 2023
2 checks passed
@shepherdjerred shepherdjerred deleted the sj/filter-version branch November 6, 2023 23:03
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