|
9 | 9 | "github.com/docker/docker/api/types/mount"
|
10 | 10 |
|
11 | 11 | "github.com/testcontainers/testcontainers-go"
|
12 |
| - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" |
13 |
| - "github.com/testcontainers/testcontainers-go/internal/testcontainerssession" |
14 | 12 | "github.com/testcontainers/testcontainers-go/wait"
|
15 | 13 | )
|
16 | 14 |
|
@@ -55,18 +53,18 @@ func SetEnvVar(variable string, value string) testcontainers.CustomizeRequestOpt
|
55 | 53 | }
|
56 | 54 |
|
57 | 55 | // WithCache sets a volume as a cache for building the k6 binary
|
58 |
| -// If a volume name is provided in the TC_K6_BUILD_CACHE, this volume is used. |
59 |
| -// If no value is provided, a volume is created and removed when the test session ends. |
| 56 | +// If a volume name is provided in the TC_K6_BUILD_CACHE, this volume is used and it will |
| 57 | +// persist across test sessions. |
| 58 | +// If no value is provided, a volume is created and automatically deleted when the test session ends. |
60 | 59 | func WithCache() testcontainers.CustomizeRequestOption {
|
61 | 60 | var volOptions *mount.VolumeOptions
|
62 | 61 |
|
63 | 62 | cacheVol := os.Getenv("TC_K6_BUILD_CACHE")
|
64 | 63 | // if no volume is provided, create one and ensure add labels for garbage collection
|
65 | 64 | if cacheVol == "" {
|
66 |
| - sessionID := testcontainerssession.SessionID() |
67 |
| - cacheVol = fmt.Sprintf("k6-cache-%s", sessionID) |
| 65 | + cacheVol = fmt.Sprintf("k6-cache-%s", testcontainers.SessionID()) |
68 | 66 | volOptions = &mount.VolumeOptions{
|
69 |
| - Labels: testcontainersdocker.DefaultLabels(sessionID), |
| 67 | + Labels: testcontainers.GenericLabels(), |
70 | 68 | }
|
71 | 69 | }
|
72 | 70 |
|
|
0 commit comments