当前位置: 首页>>代码示例>>Golang>>正文


Golang logger.TestLogBackend类代码示例

本文整理汇总了Golang中github.com/keybase/client/go/logger.TestLogBackend的典型用法代码示例。如果您正苦于以下问题:Golang TestLogBackend类的具体用法?Golang TestLogBackend怎么用?Golang TestLogBackend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestLogBackend类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AddNewAssertionForTestOrBust

// AddNewAssertionForTestOrBust is like AddNewAssertionForTest, but
// dies if there's an error.
func AddNewAssertionForTestOrBust(t logger.TestLogBackend, config Config,
	oldAssertion, newAssertion string) {
	err := AddNewAssertionForTest(config, oldAssertion, newAssertion)
	if err != nil {
		t.Fatal(err)
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:9,代码来源:test_common.go

示例2: GetRootNodeOrBust

// GetRootNodeOrBust gets the root node for the given TLF name, which
// must be canonical, creating it if necessary, and failing if there's
// an error.
func GetRootNodeOrBust(
	t logger.TestLogBackend, config Config, name string, public bool) Node {
	n, err := GetRootNodeForTest(config, name, public)
	if err != nil {
		t.Fatalf("Couldn't get root node for %s (public=%t): %v",
			name, public, err)
	}
	return n
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:12,代码来源:test_common.go

示例3: parseTlfHandleOrBust

// parseTlfHandleOrBust parses the given TLF name, which must be
// canonical, into a TLF handle, and failing if there's an error.
func parseTlfHandleOrBust(t logger.TestLogBackend, config Config,
	name string, public bool) *TlfHandle {
	ctx := context.Background()
	h, err := ParseTlfHandle(ctx, config.KBPKI(), name, public,
		config.SharingBeforeSignupEnabled())
	if err != nil {
		t.Fatalf("Couldn't parse %s (public=%t) into a TLF handle: %v",
			name, public, err)
	}
	return h
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:13,代码来源:tlf_handle_test.go

示例4: findAndKill

func findAndKill(t logger.TestLogBackend, pid int, created bool) {
	if p, err := os.FindProcess(pid); err == nil {
		if err := p.Signal(syscall.SIGTERM); err != nil {
			if err.Error() != "os: process already finished" {
				t.Fatal(err)
			}
		} else if created {
			p.Wait()
		}
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:11,代码来源:test_dynamodb_runner.go

示例5: RevokeDeviceForLocalUserOrBust

// RevokeDeviceForLocalUserOrBust revokes a device for a user in the
// given index.
func RevokeDeviceForLocalUserOrBust(t logger.TestLogBackend, config Config,
	uid keybase1.UID, index int) {
	kbd, ok := config.KeybaseDaemon().(*KeybaseDaemonLocal)
	if !ok {
		t.Fatal("Bad keybase daemon")
	}

	if err := kbd.revokeDeviceForTesting(
		config.Clock(), uid, index); err != nil {
		t.Fatal(err.Error())
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:14,代码来源:test_common.go

示例6: AddDeviceForLocalUserOrBust

// AddDeviceForLocalUserOrBust creates a new device for a user and
// returns the index for that device.
func AddDeviceForLocalUserOrBust(t logger.TestLogBackend, config Config,
	uid keybase1.UID) int {
	kbd, ok := config.KeybaseDaemon().(*KeybaseDaemonLocal)
	if !ok {
		t.Fatal("Bad keybase daemon")
	}

	index, err := kbd.addDeviceForTesting(uid, makeFakeKeys)
	if err != nil {
		t.Fatal(err.Error())
	}
	return index
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:15,代码来源:test_common.go

示例7: testRPCWithCanceledContext

func testRPCWithCanceledContext(t logger.TestLogBackend,
	serverConn net.Conn, fn func(context.Context) error) {
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		// Wait for RPC in fn to make progress.
		n, err := serverConn.Read([]byte{1})
		assert.Equal(t, n, 1)
		assert.NoError(t, err)
		cancel()
	}()

	err := fn(ctx)
	if err != context.Canceled {
		t.Fatalf("Function did not return a canceled error: %v", err)
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:16,代码来源:test_common.go

示例8: Run

// Run starts the local DynamoDB server.
func (tdr *TestDynamoDBRunner) Run(t logger.TestLogBackend) {
	// kill any old process
	if pid, err := tdr.getPid(); err == nil {
		if p, err := os.FindProcess(pid); err == nil {
			if err := p.Kill(); err != nil {
				// you might think this would satisfy !os.IsNotExist
				// but alas, no, you'd be really wrong about this.
				if err.Error() != "os: process already finished" {
					t.Fatal(err)
				}
			}
		}
	}

	// setup the command
	tmpDir := tdr.tmpDir()
	tdr.cmd = exec.Command("java",
		"-Djava.library.path="+filepath.Join(tmpDir, "DynamoDBLocal_lib"),
		"-jar", tdr.jarFilePath(), "-inMemory")

	// exec in a goroutine
	go func() {
		// start dynamo
		if err := tdr.cmd.Start(); err != nil {
			t.Fatal(err)
		}
		if err := tdr.writePid(tdr.cmd.Process.Pid); err != nil {
			t.Fatal(err)
		}
		// wait on exit
		tdr.cmd.Wait()
	}()

	// wait for it to come up
	ok := false
	for i := 0; i < 200; i++ {
		if _, err := http.Get(LocalDynamoDBUri); err == nil {
			ok = true
			break
		}
		time.Sleep(time.Millisecond * 250)
	}
	if !ok {
		t.Fatal("dynamodb did not start up cleanly")
	}
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:47,代码来源:test_dynamodb_runner.go

示例9: SwitchDeviceForLocalUserOrBust

// SwitchDeviceForLocalUserOrBust switches the current user's current device
func SwitchDeviceForLocalUserOrBust(t logger.TestLogBackend, config Config, index int) {
	name, uid, err := config.KBPKI().GetCurrentUserInfo(context.Background())
	if err != nil {
		t.Fatalf("Couldn't get UID: %v", err)
	}

	kbd, ok := config.KeybaseDaemon().(*KeybaseDaemonLocal)
	if !ok {
		t.Fatal("Bad keybase daemon")
	}

	if err := kbd.switchDeviceForTesting(uid, index); err != nil {
		t.Fatal(err.Error())
	}

	if _, ok := config.Crypto().(*CryptoLocal); !ok {
		t.Fatal("Bad crypto")
	}

	keySalt := keySaltForUserDevice(name, index)
	signingKey := MakeLocalUserSigningKeyOrBust(keySalt)
	cryptPrivateKey := MakeLocalUserCryptPrivateKeyOrBust(keySalt)
	config.SetCrypto(NewCryptoLocal(config, signingKey, cryptPrivateKey))
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:25,代码来源:test_common.go

示例10: Run

// Run starts the local DynamoDB server.
func (tdr *TestDynamoDBRunner) Run(t logger.TestLogBackend) {
	// kill any old process
	if pid, err := tdr.getPid(); err == nil {
		findAndKill(t, pid, false)
	}

	// setup the command
	tmpDir := tdr.tmpDir()
	tdr.cmd = exec.Command("java",
		"-Djava.library.path="+filepath.Join(tmpDir, "DynamoDBLocal_lib"),
		"-jar", tdr.jarFilePath(), "-inMemory")

	// exec in a goroutine
	go func() {
		// start dynamo
		if err := tdr.cmd.Start(); err != nil {
			t.Fatal(err)
		}
		if err := tdr.writePid(tdr.cmd.Process.Pid); err != nil {
			t.Fatal(err)
		}
		// wait on exit
		tdr.cmd.Wait()
	}()

	// wait for it to come up
	ok := false
	for i := 0; i < 200; i++ {
		region := aws.Region{
			DynamoDBEndpoint:        LocalDynamoDBUri,
			DynamoDBStreamsEndpoint: LocalDynamoDBUri,
		}
		auth := aws.Auth{AccessKey: "DUMMY_KEY", SecretKey: "DUMMY_SECRET"}
		server := &dynamodb.Server{Auth: auth, Region: region}
		if _, err := server.ListTables(); err != nil {
			time.Sleep(time.Millisecond * 250)
		} else {
			ok = true
			break
		}
	}
	if !ok {
		t.Fatal("dynamodb did not start up cleanly")
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:46,代码来源:test_dynamodb_runner.go

示例11: MakeTestConfigOrBust

// MakeTestConfigOrBust creates and returns a config suitable for
// unit-testing with the given list of users.
func MakeTestConfigOrBust(t logger.TestLogBackend,
	users ...libkb.NormalizedUsername) *ConfigLocal {
	config := NewConfigLocal()
	setTestLogger(config, t)

	kbfsOps := NewKBFSOpsStandard(config)
	config.SetKBFSOps(kbfsOps)
	config.SetNotifier(kbfsOps)

	config.SetBlockSplitter(&BlockSplitterSimple{64 * 1024, 8 * 1024})
	config.SetKeyManager(NewKeyManagerStandard(config))
	config.SetMDOps(NewMDOpsStandard(config))

	localUsers := MakeLocalUsers(users)
	loggedInUser := localUsers[0]

	daemon := NewKeybaseDaemonMemory(loggedInUser.UID, localUsers,
		config.Codec())
	config.SetKeybaseDaemon(daemon)

	kbpki := NewKBPKIClient(config)
	config.SetKBPKI(kbpki)

	signingKey := MakeLocalUserSigningKeyOrBust(loggedInUser.Name)
	cryptPrivateKey := MakeLocalUserCryptPrivateKeyOrBust(loggedInUser.Name)
	crypto := NewCryptoLocal(config, signingKey, cryptPrivateKey)
	config.SetCrypto(crypto)

	// see if a local remote server is specified
	bserverAddr := os.Getenv(EnvTestBServerAddr)
	if len(bserverAddr) != 0 {
		blockServer :=
			NewBlockServerRemote(config, bserverAddr)
		config.SetBlockServer(blockServer)
	} else {
		blockServer, err := NewBlockServerMemory(config)
		if err != nil {
			t.Fatal(err)
		}
		config.SetBlockServer(blockServer)
	}

	// see if a local remote server is specified
	mdServerAddr := os.Getenv(EnvTestMDServerAddr)

	var err error
	var mdServer MDServer
	var keyServer KeyServer
	if len(mdServerAddr) != 0 {
		// start/restart local in-memory DynamoDB
		runner, err := NewTestDynamoDBRunner()
		if err != nil {
			t.Fatal(err)
		}
		runner.Run(t)

		// initialize libkb -- this probably isn't the best place to do this
		// but it seems as though the MDServer rpc client is the first thing to
		// use things from it which require initialization.
		libkb.G.Init()
		libkb.G.ConfigureLogging()

		// connect to server
		mdServer = NewMDServerRemote(config, mdServerAddr)
		// for now the MD server acts as the key server in production
		keyServer = mdServer.(*MDServerRemote)
	} else {
		// create in-memory server shim
		mdServer, err = NewMDServerMemory(config)
		if err != nil {
			t.Fatal(err)
		}
		// shim for the key server too
		keyServer, err = NewKeyServerMemory(config)
		if err != nil {
			t.Fatal(err)
		}
	}
	config.SetMDServer(mdServer)
	config.SetKeyServer(keyServer)

	// turn off background flushing by default during tests
	config.noBGFlush = true

	// no auto reclamation
	config.qrPeriod = 0 * time.Second

	configs := []Config{config}
	config.allKnownConfigsForTesting = &configs

	return config
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:94,代码来源:test_common.go

示例12: CheckConfigAndShutdown

// CheckConfigAndShutdown shuts down the given config, but fails the
// test if there's an error.
func CheckConfigAndShutdown(t logger.TestLogBackend, config Config) {
	if err := config.Shutdown(); err != nil {
		t.Errorf(err.Error())
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:7,代码来源:test_common.go

示例13: AddNewKeysOrBust

// AddNewKeysOrBust adds new keys to root metadata and blows up on error.
func AddNewKeysOrBust(t logger.TestLogBackend, rmd *RootMetadata, wkb TLFWriterKeyBundle, rkb TLFReaderKeyBundle) {
	if err := rmd.AddNewKeys(wkb, rkb); err != nil {
		t.Fatal(err)
	}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:6,代码来源:test_common.go


注:本文中的github.com/keybase/client/go/logger.TestLogBackend类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。