nolint: exhaustruct // No need to use every option of 3rd party struct.
(t testing.TB)
| 31 | |
| 32 | // nolint: exhaustruct // No need to use every option of 3rd party struct. |
| 33 | func getTestValkey(t testing.TB) *ValkeyDataCache[string, []byte] { |
| 34 | ctx := context.Background() |
| 35 | repoRoot, err := filepath.Abs(filepath.Join(".", "..", "..")) |
| 36 | if err != nil { |
| 37 | t.Error(err) |
| 38 | } |
| 39 | req := testcontainers.ContainerRequest{ |
| 40 | FromDockerfile: testcontainers.FromDockerfile{ |
| 41 | Dockerfile: filepath.Join(".dev", "valkey", "Dockerfile"), |
| 42 | Context: repoRoot, |
| 43 | }, |
| 44 | ExposedPorts: []string{"6379/tcp"}, |
| 45 | WaitingFor: wait.ForLog("Ready to accept connections"), |
| 46 | Name: "webstatus-dev-test-valkey", |
| 47 | } |
| 48 | container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ |
| 49 | ContainerRequest: req, |
| 50 | Started: true, |
| 51 | }) |
| 52 | if err != nil { |
| 53 | t.Error(err) |
| 54 | } |
| 55 | |
| 56 | mappedPort, err := container.MappedPort(ctx, "6379") |
| 57 | if err != nil { |
| 58 | t.Error(err) |
| 59 | } |
| 60 | |
| 61 | cache, err := NewValkeyDataCache[string, []byte]( |
| 62 | "testPrefix", |
| 63 | "localhost", |
| 64 | mappedPort.Port(), |
| 65 | getDefatulTTL(), |
| 66 | ) |
| 67 | if err != nil { |
| 68 | t.Error(err) |
| 69 | } |
| 70 | |
| 71 | t.Cleanup(func() { |
| 72 | cache.client.Close() |
| 73 | }) |
| 74 | |
| 75 | return cache |
| 76 | } |
| 77 | |
| 78 | func TestValkeyDataCache(t *testing.T) { |
| 79 | cache := getTestValkey(t) |
no test coverage detected