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


Golang T.Evaluator方法代码示例

本文整理汇总了Golang中github.com/cronosun/buranv1/btesting.T.Evaluator方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Evaluator方法的具体用法?Golang T.Evaluator怎么用?Golang T.Evaluator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cronosun/buranv1/btesting.T的用法示例。


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

示例1: ScanMatch

func ScanMatch(t btesting.T, bucketId typing.BucketId,
	settings *ScanSettings,
	scanEntries []ScanEntry) {

	var resultsSlice []interface{}

	t.Request(btesting.Request{
		Input: btesting.Object{
			"Operation": "Scan",
			"Data": btesting.Object{
				"BucketId":      writer.BucketId(bucketId),
				"FromKey":       settings.FromKey,
				"FromExclusive": settings.FromExclusive,
				"ToKey":         settings.ToKeyOptional,
				"ToExclusive":   settings.ToExclusive,
				"Reverse":       settings.Reverse,
				"Limit":         settings.Limit,
				"Skip":          settings.Skip,
			},
		},
		Expecting: btesting.Object{
			"Code": eval.RetcodeOk(),
			"Data": btesting.Object{
				"HasMore": settings.ExpectToHaveMore,
				"Results": eval.IsAnySlice(&resultsSlice),
			},
		},
	})
	if t.Failed() {
		return
	}

	// Test if all values can be found
	var matched bool
	var collectedErrorMsgs []string
	for _, entry := range scanEntries {
		collectedErrorMsgs = nil
		matched = false
		for _, actual := range resultsSlice {
			actualObj, ok := actual.(map[string]interface{})
			if !ok {
				t.Errorf("Got something that's no a object in the results, it's %T.", actual)
				return
			}
			keyInterface := actualObj["Key"]
			t.Evaluator().Evaluate(entry.Key, keyInterface)
			if !t.Failed() {
				// Ok, we have a match
				matched = true
			} else {
				collectedErrorMsgs = append(collectedErrorMsgs, t.FailedMessage())
				// Clear failure and try next
				t.ClearFailure()
			}
		}
		if matched != entry.Match {
			// Error
			t.Errorf("Entry with key %v expected to match? %v, actually matched? %v. "+
				"All results: %v. Collected errors: %v",
				entry.Key, entry.Match, matched, resultsSlice, collectedErrorMsgs)
			return
		}
	}
}
开发者ID:cronosun,项目名称:buranv1,代码行数:64,代码来源:scan.go


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