コード例 #1
0
ファイル: elktail_test.go プロジェクト: knes1/elktail
func TestResolveField(t *testing.T) {
	model1 := map[string]interface{}{
		"@timestamp": 3711,
		"message":    2138,
		"map": map[string]interface{}{
			"test": "test",
		},
	}
	testutils.AssertEqualsString(t, "2138", eval(model1, "message"))
	testutils.AssertEqualsString(t, "test", eval(model1, "map.test"))
	testutils.AssertEqualsString(t, "", eval(model1, "map.foo"))
	testutils.AssertEqualsString(t, "", eval(model1, "bar"))
}
コード例 #2
0
func TestNewSSHTunnelFromHostStrings(t *testing.T) {
	InitLogging(os.Stderr, os.Stderr, os.Stderr, true)
	tunnel := NewSSHTunnelFromHostStrings("[email protected]:2222", "9200:localhost:9200")
	testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
	testutils.AssertEqualsString(t, tunnel.Remote.Host, "localhost")
	testutils.AssertEqualsInt(t, tunnel.Server.Port, 2222)
	testutils.AssertEqualsInt(t, tunnel.Remote.Port, 9200)
	testutils.AssertEqualsInt(t, tunnel.Local.Port, 9200)

	tunnel = NewSSHTunnelFromHostStrings("test1.example.com:2222", "")
	testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
	testutils.AssertEqualsInt(t, tunnel.Server.Port, 2222)

	tunnel = NewSSHTunnelFromHostStrings("*****@*****.**", "")
	testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
	testutils.AssertEqualsInt(t, tunnel.Server.Port, 22)

	tunnel = NewSSHTunnelFromHostStrings("test1.example.com", "")
	testutils.AssertEqualsString(t, tunnel.Server.Host, "test1.example.com")
	testutils.AssertEqualsInt(t, tunnel.Server.Port, 22)

}
コード例 #3
0
func TestExtractDate(t *testing.T) {
	tu.AssertEqualsString(t, "2016-06-17", extractYMDDate("2016-06-17T04:06", "-").Format("2006-01-02"))
	tu.AssertEqualsString(t, "2016-06-17", extractYMDDate("logstash-2016.06.17", ".").Format("2006-01-02"))
}