|
1 | 1 | package redis |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/alicebob/miniredis/v2" |
5 | | - "github.com/forceu/gokapi/internal/models" |
6 | | - "github.com/forceu/gokapi/internal/test" |
7 | | - redigo "github.com/gomodule/redigo/redis" |
8 | 4 | "log" |
9 | 5 | "os" |
10 | 6 | "slices" |
11 | 7 | "testing" |
12 | 8 | "time" |
| 9 | + |
| 10 | + "github.com/alicebob/miniredis/v2" |
| 11 | + "github.com/forceu/gokapi/internal/models" |
| 12 | + "github.com/forceu/gokapi/internal/test" |
| 13 | + redigo "github.com/gomodule/redigo/redis" |
13 | 14 | ) |
14 | 15 |
|
15 | 16 | var config = models.DbConnection{ |
@@ -253,47 +254,6 @@ func TestApiKeys(t *testing.T) { |
253 | 254 | keyName, ok := dbInstance.GetApiKeyByPublicKey("publicId") |
254 | 255 | test.IsEqualBool(t, ok, true) |
255 | 256 | test.IsEqualString(t, keyName, "publicTest") |
256 | | - |
257 | | - _, ok = dbInstance.GetSystemKey(4) |
258 | | - test.IsEqualBool(t, ok, false) |
259 | | - dbInstance.SaveApiKey(models.ApiKey{ |
260 | | - Id: "sysKey1", |
261 | | - PublicId: "publicSysKey1", |
262 | | - IsSystemKey: true, |
263 | | - UserId: 5, |
264 | | - Expiry: time.Now().Add(time.Hour).Unix(), |
265 | | - }) |
266 | | - _, ok = dbInstance.GetSystemKey(4) |
267 | | - test.IsEqualBool(t, ok, false) |
268 | | - dbInstance.SaveApiKey(models.ApiKey{ |
269 | | - Id: "sysKey2", |
270 | | - PublicId: "publicSysKey2", |
271 | | - IsSystemKey: true, |
272 | | - UserId: 4, |
273 | | - Expiry: time.Now().Add(-1 * time.Hour).Unix(), |
274 | | - }) |
275 | | - _, ok = dbInstance.GetSystemKey(4) |
276 | | - test.IsEqualBool(t, ok, false) |
277 | | - _, ok = dbInstance.GetSystemKey(5) |
278 | | - test.IsEqualBool(t, ok, true) |
279 | | - dbInstance.SaveApiKey(models.ApiKey{ |
280 | | - Id: "sysKey3", |
281 | | - PublicId: "publicSysKey2", |
282 | | - IsSystemKey: true, |
283 | | - UserId: 4, |
284 | | - Expiry: time.Now().Add(2 * time.Hour).Unix(), |
285 | | - }) |
286 | | - dbInstance.SaveApiKey(models.ApiKey{ |
287 | | - Id: "sysKey4", |
288 | | - PublicId: "publicSysKey4", |
289 | | - IsSystemKey: true, |
290 | | - UserId: 4, |
291 | | - Expiry: time.Now().Add(4 * time.Hour).Unix(), |
292 | | - }) |
293 | | - key, ok = dbInstance.GetSystemKey(4) |
294 | | - test.IsEqualBool(t, ok, true) |
295 | | - test.IsEqualString(t, key.Id, "sysKey4") |
296 | | - test.IsEqualBool(t, key.IsSystemKey, true) |
297 | 257 | } |
298 | 258 |
|
299 | 259 | func TestDatabaseProvider_IncreaseDownloadCount(t *testing.T) { |
|
0 commit comments