Skip to content

Commit cae44db

Browse files
committed
chore: use new functional option instead of custom code
1 parent fd3c7b6 commit cae44db

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

modules/couchbase/couchbase_test.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,11 @@ func TestCouchbaseWithEnterpriseContainer(t *testing.T) {
6464
testBucketUsage(t, cluster.Bucket(bucketName))
6565
}
6666

67-
type reusableCouchbase struct{}
68-
69-
func (c *reusableCouchbase) Customize(req *testcontainers.GenericContainerRequest) error {
70-
// Enable container reuse
71-
req.Reuse = true
72-
req.Name = "couchbase"
73-
return nil
74-
}
75-
7667
func TestCouchbaseWithReuse(t *testing.T) {
7768
ctx := context.Background()
7869

70+
containerName := "couchbase" + time.Now().Format(time.RFC3339)
71+
7972
bucketName := "testBucket"
8073
bucket := tccouchbase.NewBucket(bucketName).
8174
WithQuota(100).
@@ -85,7 +78,7 @@ func TestCouchbaseWithReuse(t *testing.T) {
8578
ctr, err := tccouchbase.Run(ctx,
8679
enterpriseEdition,
8780
tccouchbase.WithBuckets(bucket),
88-
&reusableCouchbase{},
81+
testcontainers.WithReuseByName(containerName),
8982
)
9083
testcontainers.CleanupContainer(t, ctr)
9184
require.NoError(t, err)
@@ -102,7 +95,7 @@ func TestCouchbaseWithReuse(t *testing.T) {
10295
// has completed.
10396
reusedCtr, err := tccouchbase.Run(ctx,
10497
enterpriseEdition,
105-
&reusableCouchbase{},
98+
testcontainers.WithReuseByName(containerName),
10699
)
107100
testcontainers.CleanupContainer(t, ctr)
108101
require.NoError(t, err)

0 commit comments

Comments
 (0)