github.com/etecs-ru/gnomock@v0.13.2/preset/mongo/options.go (about) 1 package mongo 2 3 // Option is an optional configuration of this Gnomock preset. Use available 4 // Options to configure the container 5 type Option func(*P) 6 7 // WithData sets up initial container state according to the directory 8 // structure at the given path: 9 // 10 // - path: 11 // - first 12 // - one 13 // - two 14 // - second 15 // - three 16 // 17 // For such directory structure, two databases are created: "first" and 18 // "second". Under "first" database there are two collections, "one" and "two", 19 // and under "second" database - one collection "three". 20 // 21 // Files "one", "two" and "three" are text files with JSON documents to be 22 // inserted into the database. One line should include one document. 23 // 24 // Top level files under "path" are ignored, only directories are used. 25 // Similarly, directories located anywhere besides top-level "path", are also 26 // ignored 27 func WithData(path string) Option { 28 return func(p *P) { 29 p.DataPath = path 30 } 31 } 32 33 // WithUser creates a root user with the provided name and password. This user 34 // should be used as a part of mongodb connection string. If you choose not to 35 // use your own user and password, the databases will be unprotected, and you 36 // won't need to specify any name and password in your connection string 37 func WithUser(user, pass string) Option { 38 return func(p *P) { 39 p.User = user 40 p.Password = pass 41 } 42 } 43 44 // WithVersion sets image version. 45 func WithVersion(version string) Option { 46 return func(o *P) { 47 o.Version = version 48 } 49 }