代码拉取完成,页面将自动刷新
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"testing"
dep "github.com/hashicorp/consul-template/dependency"
"github.com/hashicorp/consul/testutil"
)
var testConsul *testutil.TestServer
var testClients *dep.ClientSet
func TestMain(m *testing.M) {
consul, err := testutil.NewTestServerConfig(func(c *testutil.TestServerConfig) {
c.LogLevel = "warn"
c.Stdout = ioutil.Discard
c.Stderr = ioutil.Discard
})
log.SetOutput(ioutil.Discard)
if err != nil {
log.Fatal(fmt.Errorf("failed to start consul server: %v", err))
}
testConsul = consul
clients := dep.NewClientSet()
if err := clients.CreateConsulClient(&dep.CreateConsulClientInput{
Address: testConsul.HTTPAddr,
}); err != nil {
testConsul.Stop()
log.Fatal(err)
}
testClients = clients
exitCh := make(chan int, 1)
func() {
defer func() {
// Attempt to recover from a panic and stop the server. If we don't stop
// it, the panic will cause the server to remain running in the
// background. Here we catch the panic and the re-raise it.
if r := recover(); r != nil {
testConsul.Stop()
panic(r)
}
}()
exitCh <- m.Run()
}()
exit := <-exitCh
testConsul.Stop()
os.Exit(exit)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。