@@ -10,6 +10,7 @@ import (
1010 . "github.com/pingcap/check"
1111 "github.com/siddontang/go-mysql-elasticsearch/elastic"
1212 "github.com/siddontang/go-mysql/client"
13+ "github.com/siddontang/go-mysql/mysql"
1314)
1415
1516var my_addr = flag .String ("my_addr" , "127.0.0.1:3306" , "MySQL addr" )
@@ -42,6 +43,7 @@ func (s *riverTestSuite) SetUpSuite(c *C) {
4243 tenum ENUM("e1", "e2", "e3"),
4344 tset SET("a", "b", "c"),
4445 tbit BIT(1) default 1,
46+ tdatetime DATETIME DEFAULT NULL,
4547 PRIMARY KEY(id)) ENGINE=INNODB;
4648 `
4749
@@ -214,6 +216,9 @@ func (s *riverTestSuite) testPrepareData(c *C) {
214216 table := fmt .Sprintf ("test_river_%04d" , i )
215217 s .testExecute (c , fmt .Sprintf ("INSERT INTO %s (id, title, content, tenum, tset) VALUES (?, ?, ?, ?, ?)" , table ), 5 + i , "abc" , "hello" , "e1" , "a,b,c" )
216218 }
219+
220+ datetime := time .Now ().Format (mysql .TimeFormat )
221+ s .testExecute (c , "INSERT INTO test_river (id, title, content, tenum, tset, tdatetime) VALUES (?, ?, ?, ?, ?, ?)" , 16 , "test datetime" , "hello go 16" , "e1" , "a,b" , datetime )
217222}
218223
219224func (s * riverTestSuite ) testElasticGet (c * C , id string ) * elastic.Response {
@@ -226,6 +231,17 @@ func (s *riverTestSuite) testElasticGet(c *C, id string) *elastic.Response {
226231 return r
227232}
228233
234+ func (s * riverTestSuite ) testElasticMapping (c * C ) * elastic.MappingResponse {
235+ index := "river"
236+ docType := "river"
237+
238+ r , err := s .r .es .GetMapping (index , docType )
239+ c .Assert (err , IsNil )
240+
241+ c .Assert (r .Mapping [index ].Mappings [docType ].Properties ["tdatetime" ].Type , Equals , "date" )
242+ return r
243+ }
244+
229245func testWaitSyncDone (c * C , r * River ) {
230246 <- r .canal .WaitDumpDone ()
231247
@@ -250,6 +266,10 @@ func (s *riverTestSuite) TestRiver(c *C) {
250266
251267 testWaitSyncDone (c , s .r )
252268
269+ var mr * elastic.MappingResponse
270+ mr = s .testElasticMapping (c )
271+ c .Assert (mr .Code , Equals , 200 )
272+
253273 var r * elastic.Response
254274 r = s .testElasticGet (c , "1" )
255275 c .Assert (r .Found , Equals , true )
0 commit comments