MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / DupConf

Function DupConf

utils/config.go:26–41  ·  view source on GitHub ↗

DupConf duplicate conf file using random new listen addr to avoid failure on concurrent test cases.

(confFile string, newConfFile string)

Source from the content-addressed store, hash-verified

24
25// DupConf duplicate conf file using random new listen addr to avoid failure on concurrent test cases.
26func DupConf(confFile string, newConfFile string) (err error) {
27 // replace port in confFile
28 var fileBytes []byte
29 if fileBytes, err = ioutil.ReadFile(confFile); err != nil {
30 return
31 }
32
33 var ports []int
34 if ports, err = GetRandomPorts("127.0.0.1", 4000, 6000, 1); err != nil {
35 return
36 }
37
38 newConfBytes := bytes.Replace(fileBytes, []byte(":2230"), []byte(fmt.Sprintf(":%v", ports[0])), -1)
39
40 return ioutil.WriteFile(newConfFile, newConfBytes, 0644)
41}

Callers 5

initNodeFunction · 0.92
initNodeChainBusServiceFunction · 0.92
initNodeFunction · 0.92
TestNewPersistentCallerFunction · 0.92
TestDupConfFunction · 0.85

Calls 1

GetRandomPortsFunction · 0.85

Tested by 5

initNodeFunction · 0.74
initNodeChainBusServiceFunction · 0.74
initNodeFunction · 0.74
TestNewPersistentCallerFunction · 0.74
TestDupConfFunction · 0.68