@@ -79,6 +79,22 @@ func TestUpdate(t *testing.T) {
79
79
require .NoError (t , err , "member failed to get workspace they themselves own after update" )
80
80
require .Equal (t , version2 .ID .String (), ws .LatestBuild .TemplateVersionID .String (), "workspace must have latest template version after update" )
81
81
require .False (t , ws .Outdated , "workspace must not be outdated after update" )
82
+
83
+ // Then: the workspace must have been started with the new template version
84
+ require .Equal (t , int32 (3 ), ws .LatestBuild .BuildNumber , "workspace must have 3 builds after update" )
85
+ require .Equal (t , codersdk .WorkspaceTransitionStart , ws .LatestBuild .Transition , "latest build must be a start transition" )
86
+
87
+ // Then: the previous workspace build must be a stop transition with the old
88
+ // template version.
89
+ // This is important to ensure that the workspace resources are recreated
90
+ // correctly. Simply running a start transition with the new template
91
+ // version may not recreate resources that were changed in the new
92
+ // template version. This can happen, for example, if a user specifies
93
+ // ignore_changes in the template.
94
+ prevBuild , err := member .WorkspaceBuildByUsernameAndWorkspaceNameAndBuildNumber (ctx , codersdk .Me , ws .Name , "2" )
95
+ require .NoError (t , err , "failed to get previous workspace build" )
96
+ require .Equal (t , codersdk .WorkspaceTransitionStop , prevBuild .Transition , "previous build must be a stop transition" )
97
+ require .Equal (t , version1 .ID .String (), prevBuild .TemplateVersionID .String (), "previous build must have the old template version" )
82
98
})
83
99
}
84
100
0 commit comments