本文整理匯總了Golang中github.com/elastic/beats/libbeat/common.MapStr.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang MapStr.String方法的具體用法?Golang MapStr.String怎麽用?Golang MapStr.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/beats/libbeat/common.MapStr
的用法示例。
在下文中一共展示了MapStr.String方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestValidJSONDepthTwo
func TestValidJSONDepthTwo(t *testing.T) {
input := common.MapStr{
"msg": "{\"log\":\"{\\\"level\\\":\\\"info\\\"}\",\"stream\":\"stderr\",\"count\":3}",
"pipeline": "us1",
}
testConfig, _ = common.NewConfigFrom(map[string]interface{}{
"fields": fields,
"processArray": false,
"maxDepth": 2,
})
actual := getActualValue(t, testConfig, input)
expected := common.MapStr{
"msg": map[string]interface{}{
"log": map[string]interface{}{
"level": "info",
},
"stream": "stderr",
"count": 3,
},
"pipeline": "us1",
}
assert.Equal(t, expected.String(), actual.String())
}
示例2: TestMissingKey
func TestMissingKey(t *testing.T) {
input := common.MapStr{
"pipeline": "us1",
}
actual := getActualValue(t, testConfig, input)
expected := common.MapStr{
"pipeline": "us1",
}
assert.Equal(t, expected.String(), actual.String())
}
示例3: equalEvent
func equalEvent(expectedEvent common.MapStr, event common.MapStr) bool {
// Remove labels to test
// expectedLabels := expectedEvent["containerLabels"]
// labels := event["containerLabels"]
expectedEvent["containerLabels"] = []common.MapStr{}
event["containerLabels"] = []common.MapStr{}
// test equality
return expectedEvent.String() == event.String()
// TODO test labels
}
示例4: TestInvalidJSON
func TestInvalidJSON(t *testing.T) {
input := common.MapStr{
"msg": "{\"log\":\"{\\\"level\\\":\\\"info\\\"}\",\"stream\":\"stderr\",\"count\":3",
"pipeline": "us1",
}
actual := getActualValue(t, testConfig, input)
expected := common.MapStr{
"msg": "{\"log\":\"{\\\"level\\\":\\\"info\\\"}\",\"stream\":\"stderr\",\"count\":3",
"pipeline": "us1",
}
assert.Equal(t, expected.String(), actual.String())
}
示例5: TestFieldNotString
func TestFieldNotString(t *testing.T) {
input := common.MapStr{
"msg": 123,
"pipeline": "us1",
}
actual := getActualValue(t, testConfig, input)
expected := common.MapStr{
"msg": 123,
"pipeline": "us1",
}
assert.Equal(t, expected.String(), actual.String())
}
示例6: TestValidJSONDepthOne
func TestValidJSONDepthOne(t *testing.T) {
input := common.MapStr{
"msg": "{\"log\":\"{\\\"level\\\":\\\"info\\\"}\",\"stream\":\"stderr\",\"count\":3}",
"pipeline": "us1",
}
actual := getActualValue(t, testConfig, input)
expected := common.MapStr{
"msg": map[string]interface{}{
"log": "{\"level\":\"info\"}",
"stream": "stderr",
"count": 3,
},
"pipeline": "us1",
}
assert.Equal(t, expected.String(), actual.String())
}