- Notifications
You must be signed in to change notification settings - Fork914
fix: set preset parameters in the API rather than the frontend#17403
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/wsbuilder/wsbuilder_test.go Outdated
@@ -960,6 +961,12 @@ func withInactiveVersion(params []database.TemplateVersionParameter) func(mTx *d | |||
} | |||
} | |||
func withTemplateVersionPreset(presetID uuid.UUID) func(mTx *dbmock.MockStore) { | |||
return func(mTx *dbmock.MockStore) { | |||
mTx.EXPECT().GetPresetParametersByPresetID(gomock.Any(), presetID).Return(nil, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't understand the value of returningnil, nil
here; this won't execute your new codepath infindNewBuildParameterValue
. Can you help me understand pls?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
name: "Single Preset - No Preset Parameters But With Template Parameters", | ||
presets: []*proto.Preset{emptyPreset}, | ||
templateVersionParameters: templateVersionParameters, | ||
selectedPresetIndex: ptr.Ref(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about instead just doing something like this?
selectedPresetIndex:ptr.Ref(0), | |
selectedPreset:&emptyPreset, |
coderd/workspaces_test.go Outdated
presets: []*proto.Preset{}, | ||
templateVersionParameters: []*proto.RichParameter{}, | ||
selectedPresetIndex: -1, | ||
templateVersionParameters: templateVersionParameters, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Implementation doesn't seem to match the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Tests read much better now, thanks 👍
// Test Utility variables | ||
templateVersionParameters := []*proto.RichParameter{ | ||
{Name: "param1", Type: "string", Required: false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Only testing with unrequired params might introduce interesting blindspots, no?
Please update the referenced PR in the description |
64172d3
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Follow-up from aprevious Pull Request required some additional testing of Presets from the API perspective.
In the process of adding the new tests, I updated the API to enforce preset parameter values based on the selected preset instead of trusting whichever frontend makes the request. This avoids errors scenarios in prebuilds where a prebuild might expect a certain preset but find a different set of actual parameter values.