Skip to content

Commit

Permalink
add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
泓逸 committed May 28, 2024
1 parent 572bb7d commit 842f534
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions logstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,45 @@ func (s *LogstoreTestSuite) TestPullLogs() {
s.Nil(err)
}

func (s *LogstoreTestSuite) TestGetLogByteWithError() {
c := &LogContent{
Key: proto.String("error code"),
Value: proto.String("InternalServerError"),
}
l := &Log{
Time: proto.Uint32(uint32(time.Now().Unix())),
Contents: []*LogContent{
c,
},
}
lg := &LogGroup{
Topic: proto.String("demo topic"),
Source: proto.String("10.230.201.117"),
Logs: []*Log{
l,
},
}

shards, err := s.Logstore.ListShards()
s.True(len(shards) > 0)

err = s.Logstore.PutLogs(lg)
s.Nil(err)

cursor, err := s.Logstore.GetCursor(0, "begin")
s.Nil(err)
endCursor, err := s.Logstore.GetCursor(0, "end")
s.Nil(err)

_, _, err = s.Logstore.GetLogsBytes(1000, cursor, "", 10)
s.Contains(err.Error(), "ShardNotExist")
s.NotNil(err)

_, _, err = s.Logstore.GetLogsBytes(1000, cursor, endCursor, 10)
s.Contains(err.Error(), "ShardNotExist")
s.NotNil(err)
}

func (s *LogstoreTestSuite) TestGetLogs() {
idx, err := s.Logstore.GetIndex()
if err != nil {
Expand Down

0 comments on commit 842f534

Please sign in to comment.