2017-11-02 22:37:27 +00:00
|
|
|
package config_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
2017-12-04 16:17:13 +00:00
|
|
|
cfg "github.com/8thlight/vulcanizedb/pkg/config"
|
2017-11-02 22:37:27 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Loading the config", func() {
|
|
|
|
|
|
|
|
It("reads the private config using the environment", func() {
|
2017-12-04 16:17:13 +00:00
|
|
|
privateConfig, err := cfg.NewConfig("private")
|
2017-11-02 22:37:27 +00:00
|
|
|
|
2017-11-09 14:00:02 +00:00
|
|
|
Expect(err).To(BeNil())
|
2017-11-02 22:37:27 +00:00
|
|
|
Expect(privateConfig.Database.Hostname).To(Equal("localhost"))
|
|
|
|
Expect(privateConfig.Database.Name).To(Equal("vulcanize_private"))
|
|
|
|
Expect(privateConfig.Database.Port).To(Equal(5432))
|
2017-12-04 16:17:13 +00:00
|
|
|
expandedPath := filepath.Join(cfg.ProjectRoot(), "test_data_dir/geth.ipc")
|
2017-11-02 22:37:27 +00:00
|
|
|
Expect(privateConfig.Client.IPCPath).To(Equal(expandedPath))
|
|
|
|
})
|
|
|
|
|
2017-11-09 14:00:02 +00:00
|
|
|
It("returns an error when there is no matching config file", func() {
|
2017-12-04 16:17:13 +00:00
|
|
|
config, err := cfg.NewConfig("bad-config")
|
2017-11-09 14:00:02 +00:00
|
|
|
|
2017-12-04 16:17:13 +00:00
|
|
|
Expect(config).To(Equal(cfg.Config{}))
|
2017-11-09 14:00:02 +00:00
|
|
|
Expect(err).NotTo(BeNil())
|
|
|
|
})
|
|
|
|
|
2017-12-11 21:08:00 +00:00
|
|
|
It("reads the infura config using the environment", func() {
|
|
|
|
infuraConfig, err := cfg.NewConfig("infura")
|
|
|
|
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
Expect(infuraConfig.Database.Hostname).To(Equal("localhost"))
|
|
|
|
Expect(infuraConfig.Database.Name).To(Equal("vulcanize_private"))
|
|
|
|
Expect(infuraConfig.Database.Port).To(Equal(5432))
|
|
|
|
Expect(infuraConfig.Client.IPCPath).To(Equal("https://mainnet.infura.io/J5Vd2fRtGsw0zZ0Ov3BL"))
|
|
|
|
})
|
|
|
|
|
2017-11-02 22:37:27 +00:00
|
|
|
})
|