-
Notifications
You must be signed in to change notification settings - Fork 978
feat: mark prebuilds as such and set their preset ids #16965
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
Changes from 1 commit
82e016c
c03ea52
3693d45
beb814f
a5418ac
f4f9b17
d11fd58
61a88e4
d8b74f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…t correctly
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,6 +1307,50 @@ func TestPostWorkspaceBuild(t *testing.T) { | |
require.Equal(t, wantState, gotState) | ||
}) | ||
|
||
t.Run("SetsPresetID", func(t *testing.T) { | ||
t.Parallel() | ||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
user := coderdtest.CreateFirstUser(t, client) | ||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ | ||
Parse: echo.ParseComplete, | ||
ProvisionPlan: []*proto.Response{{ | ||
Type: &proto.Response_Plan{ | ||
Plan: &proto.PlanComplete{ | ||
Presets: []*proto.Preset{{ | ||
Name: "test", | ||
}}, | ||
}, | ||
}, | ||
}}, | ||
ProvisionApply: echo.ApplyComplete, | ||
}) | ||
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) | ||
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) | ||
workspace := coderdtest.CreateWorkspace(t, client, template.ID) | ||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) | ||
require.Nil(t, workspace.LatestBuild.TemplateVersionPresetID) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) | ||
defer cancel() | ||
|
||
presets, err := client.TemplateVersionPresets(ctx, version.ID) | ||
require.NoError(t, err) | ||
require.Equal(t, 1, len(presets)) | ||
require.Equal(t, "test", presets[0].Name) | ||
|
||
build, err := client.CreateWorkspaceBuild(ctx, workspace.ID, codersdk.CreateWorkspaceBuildRequest{ | ||
TemplateVersionID: version.ID, | ||
Transition: codersdk.WorkspaceTransitionStart, | ||
TemplateVersionPresetID: presets[0].ID, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is ID here, UUID? Should we rely on a value that is human readable instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ID is randomly generated by the database. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's say, I'm a template admin and want to modify the template with presets. I'm pushing a new template revision, it gets a new template version name and new template version ID. Does it happen the same for template version presets? will they get new IDs on every template version push, or will IDs be reused? BTW we can move this to slack to keep things rolling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes it does. |
||
}) | ||
require.NoError(t, err) | ||
require.NotNil(t, build.TemplateVersionPresetID) | ||
|
||
workspace, err = client.Workspace(ctx, workspace.ID) | ||
require.NoError(t, err) | ||
require.Equal(t, build.TemplateVersionPresetID, workspace.LatestBuild.TemplateVersionPresetID) | ||
}) | ||
|
||
t.Run("Delete", func(t *testing.T) { | ||
t.Parallel() | ||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
|
Uh oh!
There was an error while loading. Please reload this page.