コード例 #1
0
						Data: []lager.Data{{
							"config": confab.GenerateConfiguration(controller.Config),
						}},
					},
					{
						Action: "controller.write-consul-config.write-configuration.failed",
						Error:  fmt.Errorf("open %s: permission denied", filepath.Join(configDir, "config.json")),
					},
				}))
			})
		})
	})

	Describe("ConfigureClient", func() {
		It("writes the pid file", func() {
			err := controller.ConfigureClient()
			Expect(err).NotTo(HaveOccurred())

			Expect(agentRunner.WritePIDCall.CallCount).To(Equal(1))
		})

		Context("failure cases", func() {
			It("returns an error when the pid file can not be written", func() {
				agentRunner.WritePIDCall.Returns.Error = errors.New("something bad happened")

				err := controller.ConfigureClient()
				Expect(err).To(MatchError("something bad happened"))
			})
		})
	})
コード例 #2
0
ファイル: main.go プロジェクト: tkysk/consul-release
func configureClient(controller confab.Controller) {
	if err := controller.ConfigureClient(); err != nil {
		stderr.Printf("error configuring client: %s", err)
		exit(controller, 1)
	}
}