@@ -913,8 +913,12 @@ func TestWorkspaceAutobuild(t *testing.T) {
913
913
ws = coderdtest .MustWorkspace (t , client , ws .ID )
914
914
require .Equal (t , version2 .ID , ws .LatestBuild .TemplateVersionID )
915
915
})
916
+ }
917
+
918
+ func TestTemplateDoesNotAllowUserAutostop (t * testing.T ) {
919
+ t .Parallel ()
916
920
917
- t .Run ("TemplateDoesNotAllowUserAutostop " , func (t * testing.T ) {
921
+ t .Run ("TTLSetByTemplate " , func (t * testing.T ) {
918
922
t .Parallel ()
919
923
client := coderdtest .New (t , & coderdtest.Options {
920
924
IncludeProvisionerDaemon : true ,
@@ -951,6 +955,34 @@ func TestWorkspaceAutobuild(t *testing.T) {
951
955
require .Equal (t , templateTTL , template .DefaultTTLMillis )
952
956
require .Equal (t , templateTTL , * workspace .TTLMillis )
953
957
})
958
+
959
+ t .Run ("ExtendIsNotEnabledByTemplate" , func (t * testing.T ) {
960
+ t .Parallel ()
961
+ client := coderdtest .New (t , & coderdtest.Options {
962
+ IncludeProvisionerDaemon : true ,
963
+ TemplateScheduleStore : schedule .NewEnterpriseTemplateScheduleStore (agplUserQuietHoursScheduleStore ()),
964
+ })
965
+ user := coderdtest .CreateFirstUser (t , client )
966
+ version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , nil )
967
+ template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID , func (ctr * codersdk.CreateTemplateRequest ) {
968
+ ctr .AllowUserAutostop = ptr .Ref (false )
969
+ })
970
+ coderdtest .AwaitTemplateVersionJobCompleted (t , client , version .ID )
971
+ workspace := coderdtest .CreateWorkspace (t , client , user .OrganizationID , template .ID )
972
+ coderdtest .AwaitWorkspaceBuildJobCompleted (t , client , workspace .LatestBuild .ID )
973
+
974
+ require .Equal (t , false , template .AllowUserAutostop , "template should have AllowUserAutostop as false" )
975
+
976
+ ctx := testutil .Context (t , testutil .WaitShort )
977
+ ttl := 8 * time .Hour
978
+ newDeadline := time .Now ().Add (ttl + time .Hour ).UTC ()
979
+
980
+ err := client .PutExtendWorkspace (ctx , workspace .ID , codersdk.PutExtendWorkspaceRequest {
981
+ Deadline : newDeadline ,
982
+ })
983
+
984
+ require .ErrorContains (t , err , "template does not allow user autostop" )
985
+ })
954
986
}
955
987
956
988
// Blocked by autostart requirements
0 commit comments