Skip to content

Commit 06b4f53

Browse files
authored
fix: fix infinite loop while paginating tests (#144)
Signed-off-by: slayerjain <[email protected]> Signed-off-by: slayerjain <[email protected]>
1 parent 276abb1 commit 06b4f53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

keploy/keploy.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,9 @@ func (k *Keploy) newGet(url string) ([]byte, error) {
596596

597597
func (k *Keploy) fetch() []models.TestCase {
598598
var tcs []models.TestCase = []models.TestCase{}
599+
pageSize := 25
599600

600-
for i := 0; ; i += 25 {
601+
for i := 0; ; i += pageSize {
601602
url := fmt.Sprintf("%s/regression/testcase?app=%s&offset=%d&limit=%d&testCasePath=%s&mockPath=%s", k.cfg.Server.URL, k.cfg.App.Name, i, 25, k.cfg.App.TestPath, k.cfg.App.MockPath)
602603

603604
req, err := http.NewRequest("GET", url, http.NoBody)
@@ -629,10 +630,10 @@ func (k *Keploy) fetch() []models.TestCase {
629630
k.Log.Error("failed to reading testcases from keploy cloud", zap.Error(err))
630631
return nil
631632
}
632-
if len(res) == 0 {
633+
tcs = append(tcs, res...)
634+
if len(res) < pageSize {
633635
break
634636
}
635-
tcs = append(tcs, res...)
636637
eof := resp.Header.Get("EOF")
637638
if eof == "true" {
638639
break

0 commit comments

Comments
 (0)