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

js/data: ModuleV2 migration #2243

Merged
merged 1 commit into from
Nov 25, 2021
Merged

js/data: ModuleV2 migration #2243

merged 1 commit into from
Nov 25, 2021

Conversation

codebien
Copy link
Contributor

Migrated k6/data to the modules.Module (aka modules.ModuleV2) interface.

@codebien codebien self-assigned this Nov 16, 2021
@codebien codebien force-pushed the data-modulev2 branch 2 times, most recently from a815e60 to d7cc535 Compare November 19, 2021 14:05
@na-- na-- added this to the v0.36.0 milestone Nov 22, 2021
@na-- na-- requested review from oleiade and yorugac and removed request for inancgumus November 22, 2021 14:59
mstoykov
mstoykov previously approved these changes Nov 22, 2021
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

LGTM apart from a minor nitpick

js/modules/k6/data/data.go Outdated Show resolved Hide resolved
Comment on lines +60 to +62
if !ok {
return rt, fmt.Errorf("not a Data module instance")
}
Copy link
Contributor

@yorugac yorugac Nov 23, 2021

Choose a reason for hiding this comment

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

Perhaps, not even a request change, but a curiosity question: @codebien, why didn't you use require.True(t, ok) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert|require with concurrency could generate a race so I tend to avoid it for helper functions if it's possible (if the func return error). Otherwise, I would prefer a classic require.True as you suggested.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what you are talking about @codebien is that t.FailNow and co. are supposed to be called only from the goroutine that is running the test, not by anyone that is spawned by it.

We do ... not do that quite a lot it just so happens that in most cases the failure never happens 😄
I think it's perfectly fine to leave the error instead of using require.True and co., but also in this case I would expect it's perfectly fine to use it as well

Copy link
Contributor Author

@codebien codebien Nov 23, 2021

Choose a reason for hiding this comment

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

that in most cases the failure never happens

Sure, but in case of changes for refactoring, you could get the race.

but also in this case I would expect it's perfectly fine to use it as well

Yep, but I don't know how the helper could be used in the next test we will write. For this reason, I think it makes sense just for helpers shared across multiple tests. Ofc, in a single test I would prefer to use directly the assert function.

Copy link
Contributor

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

All seems fine 🙂 There is just 1 "nitpick" question.

js/modules/k6/data/data.go Outdated Show resolved Hide resolved
Migrated the js/data API to the new modules.Module interface (aka
ModuleV2).
@codebien codebien merged commit 4711640 into master Nov 25, 2021
@codebien codebien deleted the data-modulev2 branch November 25, 2021 08:45
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.

4 participants