github.com/etecs-ru/gnomock@v0.13.2/preset/mysql/options.go (about) 1 package mysql 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 // WithUser creates a new superuser with the provided credentials in the 8 // container. If not used, the default credentials are gnomock:gnomick 9 func WithUser(user, password string) Option { 10 return func(p *P) { 11 p.User = user 12 p.Password = password 13 } 14 } 15 16 // WithDatabase creates a database with the provided name in the container. If 17 // not provided, "mydb" is used by default. WithQueries, if provided, runs 18 // against the new database 19 func WithDatabase(db string) Option { 20 return func(p *P) { 21 p.DB = db 22 } 23 } 24 25 // WithQueries executes the provided queries against the database created with 26 // WithDatabase, or against default "mydb" database 27 func WithQueries(queries ...string) Option { 28 return func(p *P) { 29 p.Queries = append(p.Queries, queries...) 30 } 31 } 32 33 // WithQueriesFile sets a file name to read initial queries from. Queries from 34 // this file are executed before any other queries provided in WithQueries 35 func WithQueriesFile(file string) Option { 36 return func(p *P) { 37 p.QueriesFiles = append(p.QueriesFiles, file) 38 } 39 } 40 41 // WithVersion sets image version. 42 func WithVersion(version string) Option { 43 return func(o *P) { 44 o.Version = version 45 } 46 }