-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.go
45 lines (37 loc) · 1004 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package pgtest
type PGConfig struct {
BinDir string // Directory to look for postgresql binaries including initdb, postgres
Dir string // Directory for storing database files, removed for non-persistent configs
IsPersistent bool // Whether to make the current configuraton persistent or not
AdditionalArgs []string // Additional arguments to pass to the postgres command
}
func New() *PGConfig {
return &PGConfig{
BinDir: "",
Dir: "",
IsPersistent: false,
}
}
func (c *PGConfig) Persistent() *PGConfig {
c.IsPersistent = true
return c
}
func (c *PGConfig) From(dir string) *PGConfig {
c.BinDir = dir
return c
}
func (c *PGConfig) UseBinariesIn(dir string) *PGConfig {
c.BinDir = dir
return c
}
func (c *PGConfig) DataDir(dir string) *PGConfig {
c.Dir = dir
return c
}
func (c *PGConfig) WithAdditionalArgs(args ...string) *PGConfig {
c.AdditionalArgs = args
return c
}
func (c *PGConfig) Start() (*PG, error) {
return start(c)
}