ipld-eth-server/pkg/config/config_test.go

39 lines
971 B
Go
Raw Normal View History

2017-11-02 22:37:27 +00:00
package config_test
import (
"bytes"
2017-11-02 22:37:27 +00:00
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/spf13/viper"
2017-11-02 22:37:27 +00:00
)
var vulcanizeConfig = []byte(`
[database]
name = "dbname"
hostname = "localhost"
port = 5432
[client]
ipcPath = "IPCPATH/geth.ipc"
`)
2017-11-02 22:37:27 +00:00
var _ = Describe("Loading the config", func() {
It("reads the private config using the environment", func() {
viper.SetConfigName("config")
viper.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/")
Expect(viper.Get("client.ipcpath")).To(BeNil())
testConfig := viper.New()
testConfig.SetConfigType("toml")
err := testConfig.ReadConfig(bytes.NewBuffer(vulcanizeConfig))
Expect(err).To(BeNil())
Expect(testConfig.Get("database.hostname")).To(Equal("localhost"))
Expect(testConfig.Get("database.name")).To(Equal("dbname"))
Expect(testConfig.Get("database.port")).To(Equal(int64(5432)))
Expect(testConfig.Get("client.ipcpath")).To(Equal("IPCPATH/geth.ipc"))
})
2017-11-02 22:37:27 +00:00
})