本文整理汇总了Golang中github.com/pivotal-golang/lager/lagertest.NewTestLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTestLogger函数的具体用法?Golang NewTestLogger怎么用?Golang NewTestLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTestLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestIsDatabaseCreatedOdbcDriver2
func TestIsDatabaseCreatedOdbcDriver2(t *testing.T) {
dbName := "cf-broker-testing.create-db"
sqlClient, err := sql.Open("odbc", buildConnectionString(odbcPars))
defer sqlClient.Close()
sqlClient.Exec("drop database [" + dbName + "]")
logger = lagertest.NewTestLogger("process-controller")
mssqlProv := NewMssqlProvisioner(logger, "odbc", odbcPars)
mssqlProv.Init()
if err != nil {
t.Errorf("Provisioner init error, %v", err)
}
err = mssqlProv.CreateDatabase(dbName)
if err != nil {
t.Errorf("Database create error, %v", err)
}
// Act
exists, err := mssqlProv.IsDatabaseCreated(dbName)
// Assert
if err != nil {
t.Errorf("Check for database error, %v", err)
}
if !exists {
t.Errorf("Check for database error, expected true, but received false")
}
defer sqlClient.Exec("drop database [" + dbName + "]")
}
示例2: start
func start(creator RunnerCreator, network, addr string, argv ...string) *RunningGarden {
tmpDir := filepath.Join(
os.TempDir(),
fmt.Sprintf("test-garden-%d", ginkgo.GinkgoParallelNode()),
)
if GraphRoot == "" {
GraphRoot = filepath.Join(tmpDir, "graph")
}
graphPath := filepath.Join(GraphRoot, fmt.Sprintf("node-%d", ginkgo.GinkgoParallelNode()))
r := &RunningGarden{
GraphRoot: GraphRoot,
GraphPath: graphPath,
tmpdir: tmpDir,
logger: lagertest.NewTestLogger("garden-runner"),
Client: client.New(connection.New(network, addr)),
}
c := cmd(tmpDir, graphPath, network, addr, GardenBin, BinPath, RootFSPath, argv...)
r.process = ifrit.Invoke(creator.Create(c))
r.Pid = c.Process.Pid
return r
}
示例3: TestDeleteDatabaseOdbcDriver
func TestDeleteDatabaseOdbcDriver(t *testing.T) {
dbName := "cf-broker-testing.delete-db"
sqlClient, err := sql.Open("odbc", buildConnectionString(odbcPars))
defer sqlClient.Close()
sqlClient.Exec("drop database [" + dbName + "]")
logger = lagertest.NewTestLogger("process-controller")
mssqlProv := NewMssqlProvisioner(logger, "odbc", odbcPars)
err = mssqlProv.Init()
if err != nil {
t.Errorf("Database init error, %v", err)
}
defer mssqlProv.Close()
err = mssqlProv.CreateDatabase(dbName)
// Act
err = mssqlProv.DeleteDatabase(dbName)
// Assert
if err != nil {
t.Errorf("Database delete error, %v", err)
}
row := sqlClient.QueryRow("SELECT count(*) FROM sys.databases where name = ?", dbName)
dbCount := 0
row.Scan(&dbCount)
if dbCount != 0 {
t.Errorf("Database %s was not deleted", dbName)
}
}
示例4: start
func start(network, addr string, argv ...string) *RunningGarden {
tmpDir := filepath.Join(
os.TempDir(),
fmt.Sprintf("test-garden-%d", ginkgo.GinkgoParallelNode()),
)
Expect(os.MkdirAll(tmpDir, 0755)).To(Succeed())
if GraphRoot == "" {
GraphRoot = filepath.Join(tmpDir, "graph")
}
graphPath := filepath.Join(GraphRoot, fmt.Sprintf("node-%d", ginkgo.GinkgoParallelNode()))
stateDirPath := filepath.Join(tmpDir, "state")
depotPath := filepath.Join(tmpDir, "containers")
snapshotsPath := filepath.Join(tmpDir, "snapshots")
if err := os.MkdirAll(stateDirPath, 0755); err != nil {
Expect(err).ToNot(HaveOccurred())
}
if err := os.MkdirAll(depotPath, 0755); err != nil {
Expect(err).ToNot(HaveOccurred())
}
if err := os.MkdirAll(snapshotsPath, 0755); err != nil {
Expect(err).ToNot(HaveOccurred())
}
MustMountTmpfs(graphPath)
r := &RunningGarden{
GraphRoot: GraphRoot,
GraphPath: graphPath,
StateDirPath: stateDirPath,
DepotPath: depotPath,
SnapshotsPath: snapshotsPath,
tmpdir: tmpDir,
logger: lagertest.NewTestLogger("garden-runner"),
Client: client.New(connection.New(network, addr)),
}
c := cmd(stateDirPath, depotPath, snapshotsPath, graphPath, network, addr, GardenBin, BinPath, RootFSPath, argv...)
r.runner = ginkgomon.New(ginkgomon.Config{
Name: "garden-linux",
Command: c,
AnsiColorCode: "31m",
StartCheck: "garden-linux.started",
StartCheckTimeout: 30 * time.Second,
})
r.process = ifrit.Invoke(r.runner)
r.Pid = c.Process.Pid
return r
}
示例5: NewETCDHelper
func NewETCDHelper(serializationFormat *format.Format, cryptor encryption.Cryptor, client etcd.StoreClient) *ETCDHelper {
logger := lagertest.NewTestLogger("etcd-helper")
return &ETCDHelper{
client: client,
format: serializationFormat,
serializer: format.NewSerializer(cryptor),
logger: logger,
}
}
示例6: generateConfig
func generateConfig(natsPort, statusPort, proxyPort uint16) *config.Config {
logger := lagertest.NewTestLogger("test")
c := config.DefaultConfig(logger)
c.Port = proxyPort
c.Index = 2
c.TraceKey = "my_trace_key"
// Hardcode the IP to localhost to avoid leaving the machine while running tests
c.Ip = "127.0.0.1"
c.StartResponseDelayInterval = 10 * time.Millisecond
c.PublishStartMessageIntervalInSeconds = 10
c.PruneStaleDropletsInterval = 0
c.DropletStaleThreshold = 0
c.PublishActiveAppsInterval = 0
c.Zone = "z1"
c.EndpointTimeout = 500 * time.Millisecond
c.Status = config.StatusConfig{
Port: statusPort,
User: "user",
Pass: "pass",
}
c.Nats = []config.NatsConfig{
{
Host: "localhost",
Port: natsPort,
User: "nats",
Pass: "nats",
},
}
c.Logging = config.LoggingConfig{
File: "/dev/stdout",
Level: "info",
MetronAddress: "localhost:3457",
JobName: "router_test_z1_0",
}
c.OAuth = token_fetcher.OAuthConfig{
TokenEndpoint: "http://localhost",
Port: 8080,
}
c.RouteServiceSecret = "kCvXxNMB0JO2vinxoru9Hg=="
return c
}
示例7: Start
func Start(bin, iodaemonBin, nstarBin string, argv ...string) *RunningGarden {
network := "unix"
addr := fmt.Sprintf("/tmp/garden_%d.sock", GinkgoParallelNode())
tmpDir := filepath.Join(
os.TempDir(),
fmt.Sprintf("test-garden-%d", ginkgo.GinkgoParallelNode()),
)
if GraphRoot == "" {
GraphRoot = filepath.Join(tmpDir, "graph")
}
graphPath := filepath.Join(GraphRoot, fmt.Sprintf("node-%d", ginkgo.GinkgoParallelNode()))
depotDir := filepath.Join(tmpDir, "containers")
MustMountTmpfs(graphPath)
r := &RunningGarden{
DepotDir: depotDir,
GraphRoot: GraphRoot,
GraphPath: graphPath,
tmpdir: tmpDir,
logger: lagertest.NewTestLogger("garden-runner"),
Client: client.New(connection.New(network, addr)),
}
c := cmd(tmpDir, depotDir, graphPath, network, addr, bin, iodaemonBin, nstarBin, TarPath, RootFSPath, argv...)
r.process = ifrit.Invoke(&ginkgomon.Runner{
Name: "guardian",
Command: c,
AnsiColorCode: "31m",
StartCheck: "guardian.started",
StartCheckTimeout: 30 * time.Second,
})
r.Pid = c.Process.Pid
return r
}
示例8: TestIsDatabaseCreatedOdbcDriver
func TestIsDatabaseCreatedOdbcDriver(t *testing.T) {
dbName := "cf-broker-testing.nonexisting-db"
logger = lagertest.NewTestLogger("process-controller")
mssqlProv := NewMssqlProvisioner(logger, "odbc", odbcPars)
err := mssqlProv.Init()
if err != nil {
t.Errorf("Provisioner init error, %v", err)
}
// Act
exists, err := mssqlProv.IsDatabaseCreated(dbName)
// Assert
if err != nil {
t.Errorf("Check for database error, %v", err)
}
if exists {
t.Errorf("Check for database error, expected false, but received true")
}
}
示例9: TestCreateUserOdbcDriver
func TestCreateUserOdbcDriver(t *testing.T) {
dbName := "cf-broker-testing.create-db"
userNanme := "cf-broker-testing.create-user"
sqlClient, err := sql.Open("odbc", buildConnectionString(odbcPars))
defer sqlClient.Close()
sqlClient.Exec("drop database [" + dbName + "]")
logger = lagertest.NewTestLogger("process-controller")
mssqlProv := NewMssqlProvisioner(logger, "odbc", odbcPars)
err = mssqlProv.Init()
if err != nil {
t.Errorf("Provisioner init error, %v", err)
}
err = mssqlProv.CreateDatabase(dbName)
if err != nil {
t.Errorf("Database create error, %v", err)
}
// Act
err = mssqlProv.CreateUser(dbName, userNanme, "passwordAa_0")
// Assert
if err != nil {
t.Errorf("User create error, %v", err)
}
defer sqlClient.Exec("drop database [" + dbName + "]")
row := sqlClient.QueryRow(fmt.Sprintf("select count(*) from [%s].sys.database_principals where name = ?", dbName), userNanme)
dbCount := 0
row.Scan(&dbCount)
if dbCount == 0 {
t.Errorf("User was not created")
}
}
示例10: TestCreateDatabaseMssqlDriver
func TestCreateDatabaseMssqlDriver(t *testing.T) {
dbName := "cf-broker-testing.create-db"
sqlClient, err := sql.Open("mssql", buildConnectionString(mssqlPars))
defer sqlClient.Close()
err = sqlClient.Ping()
if err != nil {
t.Skipf("Could not connect with pure mssql driver to %v", mssqlPars)
return
}
sqlClient.Exec("drop database [" + dbName + "]")
logger = lagertest.NewTestLogger("process-controller")
mssqlProv := NewMssqlProvisioner(logger, "mssql", mssqlPars)
err = mssqlProv.Init()
if err != nil {
t.Errorf("Provisioner init error, %v", err)
}
// Act
err = mssqlProv.CreateDatabase(dbName)
// Assert
if err != nil {
t.Errorf("Database create error, %v", err)
}
defer sqlClient.Exec("drop database [" + dbName + "]")
row := sqlClient.QueryRow("SELECT count(*) FROM sys.databases where name = ?", dbName)
dbCount := 0
row.Scan(&dbCount)
if dbCount == 0 {
t.Errorf("Database was not created")
}
}
示例11:
. "github.com/onsi/gomega"
"github.com/pivotal-golang/lager/lagertest"
)
var _ = Describe("Middleware", func() {
var (
client *http.Client
ts *httptest.Server
dummyHandler http.HandlerFunc
testSink *lagertest.TestSink
)
BeforeEach(func() {
// logger
logger := lagertest.NewTestLogger("dummy-api")
// dummy handler
dummyHandler = func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Dummy handler")
}
// wrap dummy handler in logwrap
dummyHandler = handlers.LogWrap(dummyHandler, logger)
// test server
ts = httptest.NewServer(dummyHandler)
client = &http.Client{}
// test sink
示例12:
Describe("ConfigureHost", func() {
var (
vethCreator *fakedevices.FaveVethCreator
linkConfigurer *fakedevices.FakeLink
bridger *fakedevices.FakeBridge
configurer *network.NetworkConfigurer
existingBridge *net.Interface
config *network.HostConfig
)
BeforeEach(func() {
vethCreator = &fakedevices.FaveVethCreator{}
linkConfigurer = &fakedevices.FakeLink{AddIPReturns: make(map[string]error)}
bridger = &fakedevices.FakeBridge{}
configurer = &network.NetworkConfigurer{Veth: vethCreator, Link: linkConfigurer, Bridge: bridger, Logger: lagertest.NewTestLogger("test")}
existingBridge = &net.Interface{Name: "bridge"}
config = &network.HostConfig{}
})
JustBeforeEach(func() {
linkConfigurer.InterfaceByNameFunc = func(name string) (*net.Interface, bool, error) {
if name == "bridge" {
return existingBridge, true, nil
}
return nil, false, nil
}
示例13:
peerAddr = "127.0.0.1:1234"
drain = make(chan struct{})
fakeEngine = new(enginefakes.FakeEngine)
fakeWorkerClient = new(workerfakes.FakeClient)
fakeSchedulerFactory = new(jobserverfakes.FakeSchedulerFactory)
var err error
cliDownloadsDir, err = ioutil.TempDir("", "cli-downloads")
Expect(err).NotTo(HaveOccurred())
constructedEventHandler = &fakeEventHandlerFactory{}
logger := lagertest.NewTestLogger("callbacks")
sink = lager.NewReconfigurableSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG), lager.DEBUG)
logger.RegisterSink(sink)
handler, err := api.NewHandler(
logger,
externalURL,
wrappa.NewAPIAuthWrappa(true, authValidator, userContextReader),
fakeTokenGenerator,
providerFactory,
oAuthBaseURL,
示例14:
var _ = Describe("HealthRunner", func() {
var (
healthPort int
logger *lagertest.TestLogger
healthRunner health.Runner
healthProcess ifrit.Process
startupTimeout = 5 * time.Second
)
BeforeEach(func() {
healthPort = 10000 + GinkgoParallelNode()
logger = lagertest.NewTestLogger("HealthRunner Test")
healthRunner = health.NewRunner(uint(healthPort), logger)
healthProcess = ifrit.Invoke(healthRunner)
isReady := healthProcess.Ready()
Eventually(isReady, startupTimeout).Should(BeClosed(), "Error starting Health Runner")
})
AfterEach(func() {
healthProcess.Signal(os.Kill)
err := <-healthProcess.Wait()
Expect(err).ToNot(HaveOccurred())
})
Context("when the runner is running", func() {
It("accepts connections on health port", func() {
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", healthPort))
示例15:
"time"
"github.com/onsi/gomega/ghttp"
)
var _ = Describe("backend", func() {
var server *ghttp.Server
var dotNetBackend garden.Backend
var serverUri *url.URL
var logger *lagertest.TestLogger
var client *dotnet.Client
BeforeEach(func() {
server = ghttp.NewServer()
logger = lagertest.NewTestLogger("backend")
serverUri, _ = url.Parse(server.URL())
client = dotnet.NewClient(logger, serverUri)
dotNetBackend, _ = backend.NewDotNetBackend(client, logger)
})
AfterEach(func() {
//shut down the server between tests
if server.HTTPTestServer != nil {
server.Close()
}
})
Describe("Capacity", func() {
BeforeEach(func() {
server.AppendHandlers(