File tree Expand file tree Collapse file tree 2 files changed +37
-33
lines changed Expand file tree Collapse file tree 2 files changed +37
-33
lines changed Original file line number Diff line number Diff line change @@ -25,38 +25,6 @@ const rootFilePath = "/srv/firebase"
2525// ErrRootNotProvided is returned when the root path is not provided
2626var 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-
6028func gatherPorts (config partialFirebaseConfig ) ([]string , error ) {
6129 var ports []string
6230
Original file line number Diff line number Diff line change 11package firebase
22
3- import "github.com/testcontainers/testcontainers-go"
3+ import (
4+ "fmt"
5+
6+ "github.com/testcontainers/testcontainers-go"
7+ )
48
59type 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+ }
You can’t perform that action at this time.
0 commit comments