本文整理汇总了Golang中github.com/cloudfoundry-incubator/pat/config.Config.Parse方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Parse方法的具体用法?Golang Config.Parse怎么用?Golang Config.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/pat/config.Config
的用法示例。
在下文中一共展示了Config.Parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
)
BeforeEach(func() {
flags = config.NewConfig()
os.Clearenv()
InitCommandLineFlags(flags)
ListenAndServe = func(bind string) error {
listen = bind
return nil
}
})
Context("When VCAP_APP_PORT does not exist", func() {
BeforeEach(func() {
os.Clearenv()
flags.Parse([]string{})
})
It("Defaults to 8080", func() {
Ω(listen).Should(Equal(":8080"))
})
})
Context("When VCAP_APP_PORT exists", func() {
BeforeEach(func() {
os.Setenv("VCAP_APP_PORT", "1234")
flags.Parse([]string{})
})
It("Uses the env variable", func() {
Ω(listen).Should(Equal(":1234"))
示例2:
slaveStarted = false
SlaveFactory = func(conn redis.Conn, worker Worker) io.Closer {
slaveFromFactory = &dummySlave{conn, worker, false}
slaveStarted = true
return slaveFromFactory
}
workloadList = &dummyDescriberWithThreeWorkloads{}
WorkloadListFactory = func() WorkloadDescriber {
return workloadList
}
})
JustBeforeEach(func() {
flags.Parse(args)
})
Context("When -use-redis-worker is not set", func() {
It("Calls with a local worker", func() {
var worker Worker
WithConfiguredWorkerAndSlaves(func(w Worker) error {
worker = w
return nil
})
Ω(worker).Should(Equal(localWorker))
Ω(worker).ShouldNot(Equal(redisWorker))
})
It("doesn't start a slave", func() {