@@ -40,47 +40,47 @@ func TestCache(t *testing.T) {
40
40
t .Parallel ()
41
41
t .Run ("Same" , func (t * testing.T ) {
42
42
t .Parallel ()
43
- cache := wsconncache .New (func (r * http. Request , id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
43
+ cache := wsconncache .New (func (id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
44
44
return setupAgent (t , agentsdk.Metadata {}, 0 ), nil
45
45
}, 0 )
46
46
defer func () {
47
47
_ = cache .Close ()
48
48
}()
49
- conn1 , _ , err := cache .Acquire (httptest . NewRequest ( http . MethodGet , "/" , nil ), uuid .Nil )
49
+ conn1 , _ , err := cache .Acquire (uuid .Nil )
50
50
require .NoError (t , err )
51
- conn2 , _ , err := cache .Acquire (httptest . NewRequest ( http . MethodGet , "/" , nil ), uuid .Nil )
51
+ conn2 , _ , err := cache .Acquire (uuid .Nil )
52
52
require .NoError (t , err )
53
53
require .True (t , conn1 == conn2 )
54
54
})
55
55
t .Run ("Expire" , func (t * testing.T ) {
56
56
t .Parallel ()
57
57
called := atomic .NewInt32 (0 )
58
- cache := wsconncache .New (func (r * http. Request , id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
58
+ cache := wsconncache .New (func (id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
59
59
called .Add (1 )
60
60
return setupAgent (t , agentsdk.Metadata {}, 0 ), nil
61
61
}, time .Microsecond )
62
62
defer func () {
63
63
_ = cache .Close ()
64
64
}()
65
- conn , release , err := cache .Acquire (httptest . NewRequest ( http . MethodGet , "/" , nil ), uuid .Nil )
65
+ conn , release , err := cache .Acquire (uuid .Nil )
66
66
require .NoError (t , err )
67
67
release ()
68
68
<- conn .Closed ()
69
- conn , release , err = cache .Acquire (httptest . NewRequest ( http . MethodGet , "/" , nil ), uuid .Nil )
69
+ conn , release , err = cache .Acquire (uuid .Nil )
70
70
require .NoError (t , err )
71
71
release ()
72
72
<- conn .Closed ()
73
73
require .Equal (t , int32 (2 ), called .Load ())
74
74
})
75
75
t .Run ("NoExpireWhenLocked" , func (t * testing.T ) {
76
76
t .Parallel ()
77
- cache := wsconncache .New (func (r * http. Request , id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
77
+ cache := wsconncache .New (func (id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
78
78
return setupAgent (t , agentsdk.Metadata {}, 0 ), nil
79
79
}, time .Microsecond )
80
80
defer func () {
81
81
_ = cache .Close ()
82
82
}()
83
- conn , release , err := cache .Acquire (httptest . NewRequest ( http . MethodGet , "/" , nil ), uuid .Nil )
83
+ conn , release , err := cache .Acquire (uuid .Nil )
84
84
require .NoError (t , err )
85
85
time .Sleep (time .Millisecond )
86
86
release ()
@@ -107,7 +107,7 @@ func TestCache(t *testing.T) {
107
107
}()
108
108
go server .Serve (random )
109
109
110
- cache := wsconncache .New (func (r * http. Request , id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
110
+ cache := wsconncache .New (func (id uuid.UUID ) (* codersdk.WorkspaceAgentConn , error ) {
111
111
return setupAgent (t , agentsdk.Metadata {}, 0 ), nil
112
112
}, time .Microsecond )
113
113
defer func () {
@@ -130,7 +130,7 @@ func TestCache(t *testing.T) {
130
130
defer cancel ()
131
131
req := httptest .NewRequest (http .MethodGet , "/" , nil )
132
132
req = req .WithContext (ctx )
133
- conn , release , err := cache .Acquire (req , uuid .Nil )
133
+ conn , release , err := cache .Acquire (uuid .Nil )
134
134
if ! assert .NoError (t , err ) {
135
135
return
136
136
}
0 commit comments