@@ -11,7 +11,6 @@ import (
1111 "github.com/stretchr/testify/require"
1212
1313 "cdr.dev/slog"
14- "github.com/coder/coder/v2/provisionersdk"
1514 "github.com/coder/coder/v2/provisionersdk/tfpath"
1615 "github.com/coder/coder/v2/testutil"
1716)
@@ -47,9 +46,12 @@ func TestStaleSessions(t *testing.T) {
4746 addSessionFolder (t , fs , second , now .Add (- 8 * 24 * time .Hour ))
4847 third := tfpath .Session (workDirectory , uuid .NewString ())
4948 addSessionFolder (t , fs , third , now .Add (- 9 * 24 * time .Hour ))
49+ // tfDir is a fake session that will clean up the others
50+ tfDir := tfpath .Session (workDirectory , uuid .NewString ())
5051
5152 // when
52- provisionersdk .CleanStaleSessions (ctx , workDirectory , fs , now , logger )
53+ err := tfDir .CleanStaleSessions (ctx , logger , fs , now )
54+ require .NoError (t , err )
5355
5456 // then
5557 entries , err := afero .ReadDir (fs , workDirectory )
@@ -70,9 +72,11 @@ func TestStaleSessions(t *testing.T) {
7072 addSessionFolder (t , fs , first , now .Add (- 7 * 24 * time .Hour ))
7173 second := tfpath .Session (workDirectory , uuid .NewString ())
7274 addSessionFolder (t , fs , second , now .Add (- 6 * 24 * time .Hour ))
75+ tfDir := tfpath .Session (workDirectory , uuid .NewString ())
7376
7477 // when
75- provisionersdk .CleanStaleSessions (ctx , workDirectory , fs , now , logger )
78+ err := tfDir .CleanStaleSessions (ctx , logger , fs , now )
79+ require .NoError (t , err )
7680
7781 // then
7882 entries , err := afero .ReadDir (fs , workDirectory )
@@ -94,9 +98,11 @@ func TestStaleSessions(t *testing.T) {
9498 addSessionFolder (t , fs , first , now .Add (- 6 * 24 * time .Hour ))
9599 second := tfpath .Session (workDirectory , uuid .NewString ())
96100 addSessionFolder (t , fs , second , now .Add (- 5 * 24 * time .Hour ))
101+ tfDir := tfpath .Session (workDirectory , uuid .NewString ())
97102
98103 // when
99- provisionersdk .CleanStaleSessions (ctx , workDirectory , fs , now , logger )
104+ err := tfDir .CleanStaleSessions (ctx , logger , fs , now )
105+ require .NoError (t , err )
100106
101107 // then
102108 entries , err := afero .ReadDir (fs , workDirectory )
0 commit comments