@@ -702,6 +702,41 @@ func TestExecuteAutostopSuspendedUser(t *testing.T) {
702
702
assert .Equal (t , codersdk .WorkspaceStatusStopped , workspaceBuild .Status )
703
703
}
704
704
705
+ func TestExecutorWorkspaceAutostopNoWaitChangedMyMind (t * testing.T ) {
706
+ t .Parallel ()
707
+
708
+ var (
709
+ ctx = context .Background ()
710
+ tickCh = make (chan time.Time )
711
+ statsCh = make (chan autobuild.Stats )
712
+ client = coderdtest .New (t , & coderdtest.Options {
713
+ AutobuildTicker : tickCh ,
714
+ IncludeProvisionerDaemon : true ,
715
+ AutobuildStats : statsCh ,
716
+ })
717
+ // Given: we have a user with a workspace
718
+ workspace = mustProvisionWorkspace (t , client )
719
+ )
720
+
721
+ // Given: the user changes their mind and decides their workspace should not autostop
722
+ err := client .UpdateWorkspaceTTL (ctx , workspace .ID , codersdk.UpdateWorkspaceTTLRequest {TTLMillis : nil })
723
+ require .NoError (t , err )
724
+
725
+ // Then: the deadline should be set to zero
726
+ updated := coderdtest .MustWorkspace (t , client , workspace .ID )
727
+ assert .True (t , ! updated .LatestBuild .Deadline .Valid )
728
+
729
+ // When: the autobuild executor ticks after the original deadline
730
+ go func () {
731
+ tickCh <- workspace .LatestBuild .Deadline .Time .Add (time .Minute )
732
+ }()
733
+
734
+ // Then: the workspace should not stop
735
+ stats := <- statsCh
736
+ assert .Len (t , stats .Errors , 0 )
737
+ assert .Len (t , stats .Transitions , 0 )
738
+ }
739
+
705
740
func TestExecutorAutostartMultipleOK (t * testing.T ) {
706
741
if os .Getenv ("DB" ) == "" {
707
742
t .Skip (`This test only really works when using a "real" database, similar to a HA setup` )
0 commit comments