Skip to content

Commit

Permalink
Merge pull request #1129 from k1LoW/fix-loop
Browse files Browse the repository at this point in the history
Fix a bug that caused store values to be lost when using `loop:`.
  • Loading branch information
k1LoW authored Dec 24, 2024
2 parents 780265c + d3cbab9 commit ffeecef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 0 additions & 9 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ func (s *store) recordAsMapped(idx int, v map[string]any) {
if !s.useMap {
panic("recordAsMapped can only be used if useMap = true")
}
if s.loopIndex != nil && *s.loopIndex > 0 {
// delete values of prevous loop
latestKey := s.stepMapKeys[idx-1]
delete(s.stepMap, latestKey)
}
k := s.stepMapKeys[idx]
s.stepMap[k] = v
}
Expand All @@ -127,10 +122,6 @@ func (s *store) recordAsListed(idx int, v map[string]any) {
if s.useMap {
panic("recordAsMapped can only be used if useMap = false")
}
if s.loopIndex != nil && *s.loopIndex > 0 {
// delete values of prevous loop
delete(s.stepList, idx-1)
}
s.stepList[idx] = v
}

Expand Down
12 changes: 12 additions & 0 deletions testdata/book/loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@ steps:
// 11,12
steps[7].res.rawBody contains "12"
&& loopmap['hi'].rawBody contains "12"
-
desc: Check that the values of the steps are not lost when using loop
test: |
steps[0] != null
&& steps[1] != null
&& steps[2] != null
&& steps[3] != null
&& steps[4] != null
&& steps[5] != null
&& steps[6] != null
&& steps[7] != null
&& steps[8] != null

0 comments on commit ffeecef

Please sign in to comment.