@@ -21,7 +21,7 @@ func TestInstanceManager(t *testing.T) {
21
21
}
22
22
23
23
tip := & testInstanceProvider {}
24
- im := New (tip )
24
+ im := NewWithOptions (tip , defaultInstanceTTL , defaultInstanceCleanup , time . Millisecond )
25
25
26
26
t .Run ("When getting instance should create a new instance" , func (t * testing.T ) {
27
27
instance , err := im .Get (ctx , pCtx )
@@ -43,11 +43,6 @@ func TestInstanceManager(t *testing.T) {
43
43
Updated : time .Now (),
44
44
},
45
45
}
46
- origDisposeTTL := disposeTTL
47
- disposeTTL = time .Millisecond
48
- t .Cleanup (func () {
49
- disposeTTL = origDisposeTTL
50
- })
51
46
newInstance , err := im .Get (ctx , pCtxUpdated )
52
47
53
48
t .Run ("New instance should be created" , func (t * testing.T ) {
@@ -79,17 +74,8 @@ func TestInstanceManagerExpiration(t *testing.T) {
79
74
},
80
75
}
81
76
82
- origInstanceTTL := instanceTTL
83
- instanceTTL = time .Millisecond
84
- origInstanceCleanup := instanceCleanup
85
- instanceCleanup = 2 * time .Millisecond
86
- t .Cleanup (func () {
87
- instanceTTL = origInstanceTTL
88
- instanceCleanup = origInstanceCleanup
89
- })
90
-
91
77
tip := & testInstanceProvider {}
92
- im := New (tip )
78
+ im := NewWithOptions (tip , time . Millisecond , 2 * time . Millisecond , defaultDisposeTTL )
93
79
94
80
instance , err := im .Get (ctx , pCtx )
95
81
require .NoError (t , err )
@@ -157,12 +143,6 @@ func TestInstanceManagerConcurrency(t *testing.T) {
157
143
})
158
144
159
145
t .Run ("Check possible race condition issues when re-creating instance on settings update" , func (t * testing.T ) {
160
- origDisposeTTL := disposeTTL
161
- disposeTTL = time .Millisecond
162
- t .Cleanup (func () {
163
- disposeTTL = origDisposeTTL
164
- })
165
-
166
146
ctx := context .Background ()
167
147
initialPCtx := backend.PluginContext {
168
148
OrgID : 1 ,
@@ -171,7 +151,7 @@ func TestInstanceManagerConcurrency(t *testing.T) {
171
151
},
172
152
}
173
153
tip := & testInstanceProvider {}
174
- im := New (tip )
154
+ im := NewWithOptions (tip , defaultInstanceTTL , defaultInstanceCleanup , time . Millisecond )
175
155
// Creating initial instance with old contexts
176
156
instanceToDispose , _ := im .Get (ctx , initialPCtx )
177
157
0 commit comments