本文整理汇总了Golang中github.com/outbrain/golib/tests.S函数的典型用法代码示例。如果您正苦于以下问题:Golang S函数的具体用法?Golang S怎么用?Golang S使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了S函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestBinlogPrevious
func TestBinlogPrevious(t *testing.T) {
c1 := BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
cres, err := c1.PreviousFileCoordinates()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c1.Type, cres.Type)
test.S(t).ExpectEquals(cres.LogFile, "mysql-bin.00016")
c2 := BinlogCoordinates{LogFile: "mysql-bin.00100", LogPos: 104}
cres, err = c2.PreviousFileCoordinates()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c1.Type, cres.Type)
test.S(t).ExpectEquals(cres.LogFile, "mysql-bin.00099")
c3 := BinlogCoordinates{LogFile: "mysql.00.prod.com.00100", LogPos: 104}
cres, err = c3.PreviousFileCoordinates()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c1.Type, cres.Type)
test.S(t).ExpectEquals(cres.LogFile, "mysql.00.prod.com.00099")
c4 := BinlogCoordinates{LogFile: "mysql.00.prod.com.00000", LogPos: 104}
_, err = c4.PreviousFileCoordinates()
test.S(t).ExpectNotNil(err)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:27,代码来源:instance_test.go
示例2: TestBinlogFileNumberDistance
func TestBinlogFileNumberDistance(t *testing.T) {
c1 := BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
fileNum, numLen := c1.FileNumber()
test.S(t).ExpectEquals(fileNum, 17)
test.S(t).ExpectEquals(numLen, 5)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:7,代码来源:instance_test.go
示例3: TestInstanceKeyMapReadJSON
func TestInstanceKeyMapReadJSON(t *testing.T) {
json := `[{"Hostname":"host1","Port":3306},{"Hostname":"host2","Port":3306}]`
m := *NewInstanceKeyMap()
m.ReadJson(json)
test.S(t).ExpectEquals(len(m), 2)
test.S(t).ExpectTrue(m[key1])
test.S(t).ExpectTrue(m[key2])
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:8,代码来源:instance_test.go
示例4: TestBinlogFileNumber
func TestBinlogFileNumber(t *testing.T) {
c1 := BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
c2 := BinlogCoordinates{LogFile: "mysql-bin.00022", LogPos: 104}
test.S(t).ExpectEquals(c1.FileNumberDistance(&c1), 0)
test.S(t).ExpectEquals(c1.FileNumberDistance(&c2), 5)
test.S(t).ExpectEquals(c2.FileNumberDistance(&c1), -5)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:8,代码来源:instance_test.go
示例5: TestIsSmallerMajorVersion
func TestIsSmallerMajorVersion(t *testing.T) {
i55 := Instance{Version: "5.5"}
i5517 := Instance{Version: "5.5.17"}
i56 := Instance{Version: "5.6"}
test.S(t).ExpectFalse(i55.IsSmallerMajorVersion(&i5517))
test.S(t).ExpectFalse(i56.IsSmallerMajorVersion(&i5517))
test.S(t).ExpectTrue(i55.IsSmallerMajorVersion(&i56))
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:9,代码来源:instance_test.go
示例6: TestInstanceKeyMapToJSON
func TestInstanceKeyMapToJSON(t *testing.T) {
m := *NewInstanceKeyMap()
m.AddKey(key1)
m.AddKey(key2)
json, err := m.ToJSON()
test.S(t).ExpectNil(err)
ok := (json == `[{"Hostname":"host1","Port":3306},{"Hostname":"host2","Port":3306}]`) || (json == `[{"Hostname":"host2","Port":3306},{"Hostname":"host1","Port":3306}]`)
test.S(t).ExpectTrue(ok)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:9,代码来源:instance_test.go
示例7: TestInstanceKeyValid
func TestInstanceKeyValid(t *testing.T) {
test.S(t).ExpectTrue(key1.IsValid())
i, err := ParseInstanceKey("_:3306")
test.S(t).ExpectNil(err)
test.S(t).ExpectFalse(i.IsValid())
i, err = ParseInstanceKey("//myhost:3306")
test.S(t).ExpectNil(err)
test.S(t).ExpectFalse(i.IsValid())
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:9,代码来源:instance_test.go
示例8: TestIsGenerallyValidAsBinlogSource
func TestIsGenerallyValidAsBinlogSource(t *testing.T) {
instances, _ := generateTestInstances()
for _, instance := range instances {
test.S(t).ExpectFalse(isGenerallyValidAsBinlogSource(instance))
}
applyGeneralGoodToGoReplicationParams(instances)
for _, instance := range instances {
test.S(t).ExpectTrue(isGenerallyValidAsBinlogSource(instance))
}
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:10,代码来源:instance_topology_test.go
示例9: TestRemoveInstance
func TestRemoveInstance(t *testing.T) {
{
instances := [](*Instance){&instance1, &instance2}
test.S(t).ExpectEquals(len(instances), 2)
instances = RemoveNilInstances(instances)
test.S(t).ExpectEquals(len(instances), 2)
}
{
instances := [](*Instance){&instance1, nil, &instance2}
test.S(t).ExpectEquals(len(instances), 3)
instances = RemoveNilInstances(instances)
test.S(t).ExpectEquals(len(instances), 2)
}
{
instances := [](*Instance){&instance1, &instance2}
test.S(t).ExpectEquals(len(instances), 2)
instances = RemoveInstance(instances, &key1)
test.S(t).ExpectEquals(len(instances), 1)
instances = RemoveInstance(instances, &key1)
test.S(t).ExpectEquals(len(instances), 1)
instances = RemoveInstance(instances, &key2)
test.S(t).ExpectEquals(len(instances), 0)
instances = RemoveInstance(instances, &key2)
test.S(t).ExpectEquals(len(instances), 0)
}
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:26,代码来源:instance_test.go
示例10: TestSortInstancesSameCoordinatesDifferingVersions
func TestSortInstancesSameCoordinatesDifferingVersions(t *testing.T) {
instances, instancesMap := generateTestInstances()
for _, instance := range instances {
instance.ExecBinlogCoordinates = instances[0].ExecBinlogCoordinates
}
instancesMap[i810Key.StringCode()].Version = "5.5.1"
instancesMap[i720Key.StringCode()].Version = "5.7.8"
sortInstances(instances)
test.S(t).ExpectEquals(instances[0].Key, i810Key)
test.S(t).ExpectEquals(instances[5].Key, i720Key)
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:11,代码来源:instance_topology_test.go
示例11: TestSortInstancesSameCoordinatesDifferingBinlogFormats
func TestSortInstancesSameCoordinatesDifferingBinlogFormats(t *testing.T) {
instances, instancesMap := generateTestInstances()
for _, instance := range instances {
instance.ExecBinlogCoordinates = instances[0].ExecBinlogCoordinates
instance.Binlog_format = "MIXED"
}
instancesMap[i810Key.StringCode()].Binlog_format = "STATEMENT"
instancesMap[i720Key.StringCode()].Binlog_format = "ROW"
sortInstances(instances)
test.S(t).ExpectEquals(instances[0].Key, i810Key)
test.S(t).ExpectEquals(instances[5].Key, i720Key)
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:12,代码来源:instance_topology_test.go
示例12: TestCanReplicateFrom
func TestCanReplicateFrom(t *testing.T) {
i55 := Instance{Key: key1, Version: "5.5"}
i56 := Instance{Key: key2, Version: "5.6"}
var canReplicate bool
canReplicate, _ = i56.CanReplicateFrom(&i55)
test.S(t).ExpectEquals(canReplicate, false) //binlog not yet enabled
i55.LogBinEnabled = true
i55.LogSlaveUpdatesEnabled = true
i56.LogBinEnabled = true
i56.LogSlaveUpdatesEnabled = true
canReplicate, _ = i56.CanReplicateFrom(&i55)
test.S(t).ExpectEquals(canReplicate, false) //serverid not set
i55.ServerID = 55
i56.ServerID = 56
canReplicate, err := i56.CanReplicateFrom(&i55)
test.S(t).ExpectNil(err)
test.S(t).ExpectTrue(canReplicate)
canReplicate, _ = i55.CanReplicateFrom(&i56)
test.S(t).ExpectFalse(canReplicate)
iStatement := Instance{Key: key1, Binlog_format: "STATEMENT", ServerID: 1, Version: "5.5", LogBinEnabled: true, LogSlaveUpdatesEnabled: true}
iRow := Instance{Key: key2, Binlog_format: "ROW", ServerID: 2, Version: "5.5", LogBinEnabled: true, LogSlaveUpdatesEnabled: true}
canReplicate, err = iRow.CanReplicateFrom(&iStatement)
test.S(t).ExpectNil(err)
test.S(t).ExpectTrue(canReplicate)
canReplicate, _ = iStatement.CanReplicateFrom(&iRow)
test.S(t).ExpectFalse(canReplicate)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:32,代码来源:instance_test.go
示例13: TestRecoveryPeriodBlock
func TestRecoveryPeriodBlock(t *testing.T) {
{
c := newConfiguration()
c.RecoveryPeriodBlockSeconds = 0
c.RecoveryPeriodBlockMinutes = 0
err := c.postReadAdjustments()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c.RecoveryPeriodBlockSeconds, 0)
}
{
c := newConfiguration()
c.RecoveryPeriodBlockSeconds = 30
c.RecoveryPeriodBlockMinutes = 1
err := c.postReadAdjustments()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c.RecoveryPeriodBlockSeconds, 30)
}
{
c := newConfiguration()
c.RecoveryPeriodBlockSeconds = 0
c.RecoveryPeriodBlockMinutes = 2
err := c.postReadAdjustments()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c.RecoveryPeriodBlockSeconds, 120)
}
{
c := newConfiguration()
c.RecoveryPeriodBlockSeconds = 15
c.RecoveryPeriodBlockMinutes = 0
err := c.postReadAdjustments()
test.S(t).ExpectNil(err)
test.S(t).ExpectEquals(c.RecoveryPeriodBlockSeconds, 15)
}
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:34,代码来源:config_test.go
示例14: TestGetSynonymPath
func TestGetSynonymPath(t *testing.T) {
api := HttpAPI{}
{
path := "relocate-slaves"
synonym := api.getSynonymPath(path)
test.S(t).ExpectEquals(synonym, "relocate-replicas")
}
{
path := "relocate-slaves/:host/:port"
synonym := api.getSynonymPath(path)
test.S(t).ExpectEquals(synonym, "relocate-replicas/:host/:port")
}
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:14,代码来源:api_test.go
示例15: TestKnownCommands
func TestKnownCommands(t *testing.T) {
Cli("help", false, "localhost:9999", "localhost:9999", "orc", "no-reason", "1m", ".", "no-alias", "no-pool", "")
commandsMap := make(map[string]string)
for _, command := range knownCommands {
commandsMap[command.Command] = command.Section
}
test.S(t).ExpectEquals(commandsMap["no-such-command"], "")
test.S(t).ExpectEquals(commandsMap["relocate"], "Smart relocation")
test.S(t).ExpectEquals(commandsMap["relocate-slaves"], "")
test.S(t).ExpectEquals(commandsMap["relocate-replicas"], "Smart relocation")
for _, synonym := range commandSynonyms {
test.S(t).ExpectNotEquals(commandsMap[synonym], "")
}
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:16,代码来源:cli_test.go
示例16: TestInstanceKeyMapToCommaDelimitedList
func TestInstanceKeyMapToCommaDelimitedList(t *testing.T) {
m := *NewInstanceKeyMap()
m.AddKey(key1)
m.AddKey(key2)
res := m.ToCommaDelimitedList()
ok := (res == `host1:3306,host2:3306`) || (res == `host2:3306,host1:3306`)
test.S(t).ExpectTrue(ok)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:9,代码来源:instance_test.go
示例17: TestIsGenerallyValidAsCandidateReplica
func TestIsGenerallyValidAsCandidateReplica(t *testing.T) {
instances, _ := generateTestInstances()
for _, instance := range instances {
test.S(t).ExpectFalse(isGenerallyValidAsCandidateReplica(instance))
}
for _, instance := range instances {
instance.IsLastCheckValid = true
instance.LogBinEnabled = true
instance.LogSlaveUpdatesEnabled = false
}
for _, instance := range instances {
test.S(t).ExpectFalse(isGenerallyValidAsCandidateReplica(instance))
}
applyGeneralGoodToGoReplicationParams(instances)
for _, instance := range instances {
test.S(t).ExpectTrue(isGenerallyValidAsCandidateReplica(instance))
}
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:18,代码来源:instance_topology_test.go
示例18: TestChooseCandidateReplicaNoCandidateReplica
func TestChooseCandidateReplicaNoCandidateReplica(t *testing.T) {
instances, _ := generateTestInstances()
for _, instance := range instances {
instance.IsLastCheckValid = true
instance.LogBinEnabled = true
instance.LogSlaveUpdatesEnabled = false
}
_, _, _, _, _, err := chooseCandidateReplica(instances)
test.S(t).ExpectNotNil(err)
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:10,代码来源:instance_topology_test.go
注:本文中的github.com/outbrain/golib/tests.S函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论