Skip to content

Commit fb2c0aa

Browse files
committed
chore: move options to its file
1 parent 34409eb commit fb2c0aa

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

modules/firebase/firebase.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,6 @@ const rootFilePath = "/srv/firebase"
2525
// ErrRootNotProvided is returned when the root path is not provided
2626
var ErrRootNotProvided = errors.New("firebase root not provided (WithRoot is required)")
2727

28-
// WithRoot sets the directory which is copied to the destination container as firebase root
29-
func WithRoot(rootPath string) testcontainers.CustomizeRequestOption {
30-
return testcontainers.WithFiles(testcontainers.ContainerFile{
31-
HostFilePath: rootPath,
32-
ContainerFilePath: rootFilePath,
33-
FileMode: 0o775,
34-
})
35-
}
36-
37-
// WithData names the data directory (by default under firebase root), can be used as a way of setting up fixtures.
38-
// Usage of absolute path will imply that the user knows how to mount external directory into the container.
39-
func WithData(dataPath string) testcontainers.CustomizeRequestOption {
40-
return func(req *testcontainers.GenericContainerRequest) error {
41-
req.Env["DATA_DIRECTORY"] = dataPath
42-
return nil
43-
}
44-
}
45-
46-
const cacheFilePath = "/root/.cache/firebase"
47-
48-
// WithCache enables firebase binary cache based on session (meaningful only when multiple tests are used)
49-
func WithCache() testcontainers.CustomizeRequestOption {
50-
volumeName := fmt.Sprintf("firestore-cache-%s", testcontainers.SessionID())
51-
52-
return testcontainers.WithMounts(testcontainers.ContainerMount{
53-
Source: testcontainers.DockerVolumeMountSource{
54-
Name: volumeName,
55-
},
56-
Target: cacheFilePath,
57-
})
58-
}
59-
6028
func gatherPorts(config partialFirebaseConfig) ([]string, error) {
6129
var ports []string
6230

modules/firebase/options.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package firebase
22

3-
import "github.com/testcontainers/testcontainers-go"
3+
import (
4+
"fmt"
5+
6+
"github.com/testcontainers/testcontainers-go"
7+
)
48

59
type options struct {
610
emulators map[string]string
@@ -17,3 +21,35 @@ func (o Option) Customize(*testcontainers.GenericContainerRequest) error {
1721
// NOOP to satisfy interface.
1822
return nil
1923
}
24+
25+
// WithRoot sets the directory which is copied to the destination container as firebase root
26+
func WithRoot(rootPath string) testcontainers.CustomizeRequestOption {
27+
return testcontainers.WithFiles(testcontainers.ContainerFile{
28+
HostFilePath: rootPath,
29+
ContainerFilePath: rootFilePath,
30+
FileMode: 0o775,
31+
})
32+
}
33+
34+
// WithData names the data directory (by default under firebase root), can be used as a way of setting up fixtures.
35+
// Usage of absolute path will imply that the user knows how to mount external directory into the container.
36+
func WithData(dataPath string) testcontainers.CustomizeRequestOption {
37+
return func(req *testcontainers.GenericContainerRequest) error {
38+
req.Env["DATA_DIRECTORY"] = dataPath
39+
return nil
40+
}
41+
}
42+
43+
const cacheFilePath = "/root/.cache/firebase"
44+
45+
// WithCache enables firebase binary cache based on session (meaningful only when multiple tests are used)
46+
func WithCache() testcontainers.CustomizeRequestOption {
47+
volumeName := fmt.Sprintf("firestore-cache-%s", testcontainers.SessionID())
48+
49+
return testcontainers.WithMounts(testcontainers.ContainerMount{
50+
Source: testcontainers.DockerVolumeMountSource{
51+
Name: volumeName,
52+
},
53+
Target: cacheFilePath,
54+
})
55+
}

0 commit comments

Comments
 (0)