github.com/etecs-ru/gnomock@v0.13.2/preset/cockroachdb/options.go (about)

     1  package cockroachdb
     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  // WithVersion sets image version.
     8  func WithVersion(version string) Option {
     9  	return func(o *P) {
    10  		o.Version = version
    11  	}
    12  }
    13  
    14  // WithDatabase creates a database with the provided name in the container.
    15  // WithQueries, if provided, runs against the new database.
    16  func WithDatabase(db string) Option {
    17  	return func(p *P) {
    18  		p.DB = db
    19  	}
    20  }
    21  
    22  // WithQueries executes the provided queries against the database created with
    23  // WithDatabase, or against the default database.
    24  func WithQueries(queries ...string) Option {
    25  	return func(p *P) {
    26  		p.Queries = append(p.Queries, queries...)
    27  	}
    28  }
    29  
    30  // WithQueriesFile sets a file name to read initial queries from. Queries from
    31  // this file are executed before any other queries provided in WithQueries.
    32  func WithQueriesFile(file string) Option {
    33  	return func(p *P) {
    34  		p.QueriesFiles = append(p.QueriesFiles, file)
    35  	}
    36  }