예제 #1
0
				"verify_outgoing": true,
				"verify_incoming": true,
				"verify_server_hostname": true,
				"ca_file": "/var/vcap/jobs/consul_agent/config/certs/ca.crt",
				"key_file": "/var/vcap/jobs/consul_agent/config/certs/agent.key",
				"cert_file": "/var/vcap/jobs/consul_agent/config/certs/agent.crt"
			}`))

			Expect(logger.Messages).To(ContainSequence([]fakes.LoggerMessage{
				{
					Action: "controller.write-consul-config.generate-configuration",
				},
				{
					Action: "controller.write-consul-config.write-configuration",
					Data: []lager.Data{{
						"config": confab.GenerateConfiguration(controller.Config),
					}},
				},
				{
					Action: "controller.write-consul-config.success",
				},
			}))
		})

		Context("failure cases", func() {
			It("returns an error when the config file can't be written to", func() {
				err := os.Chmod(configDir, 0000)
				Expect(err).NotTo(HaveOccurred())

				err = controller.WriteConsulConfig()
				Expect(err).To(MatchError(ContainSubstring("permission denied")))
package confab_test

import (
	"confab"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("ConsulConfigDefiner", func() {
	Describe("GenerateConfiguration", func() {
		var consulConfig confab.ConsulConfig

		BeforeEach(func() {
			consulConfig = confab.GenerateConfiguration(confab.Config{})
		})

		Describe("datacenter", func() {
			It("defaults to empty string", func() {
				Expect(consulConfig.Datacenter).To(Equal(""))
			})

			Context("when the `consul.agent.datacenter` property is set", func() {
				It("uses that value", func() {
					consulConfig = confab.GenerateConfiguration(confab.Config{
						Consul: confab.ConfigConsul{
							Agent: confab.ConfigConsulAgent{
								Datacenter: "my-datacenter",
							},
						},
					})