Skip to content

Commit

Permalink
address PR comments (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
toddtreece authored Feb 28, 2022
1 parent 499cee9 commit a6e5378
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 0 additions & 3 deletions experimental/e2e/fixture/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
func TestFixtureAdd(t *testing.T) {
t.Run("should add request and response to fixture store", func(t *testing.T) {
req, res := setupFixture()
defer req.Body.Close()
defer res.Body.Close()
store := newFakeStorage()
f := fixture.NewFixture(store)
Expand All @@ -30,7 +29,6 @@ func TestFixtureAdd(t *testing.T) {

t.Run("should apply request processor", func(t *testing.T) {
req, res := setupFixture()
defer req.Body.Close()
defer res.Body.Close()
store := newFakeStorage()
f := fixture.NewFixture(store)
Expand All @@ -46,7 +44,6 @@ func TestFixtureAdd(t *testing.T) {

t.Run("should apply response processor", func(t *testing.T) {
req, res := setupFixture()
defer req.Body.Close()
defer res.Body.Close()
store := newFakeStorage()
f := fixture.NewFixture(store)
Expand Down
8 changes: 5 additions & 3 deletions experimental/e2e/storage/har.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

// HARStorage is a Storage implementation that stores requests and responses in HAR format on disk.
type HARStorage struct {
lock sync.Mutex
lock sync.RWMutex
path string
har *har.HAR
currentTime func() time.Time
Expand Down Expand Up @@ -165,8 +165,8 @@ func (s *HARStorage) Add(req *http.Request, res *http.Response) {
// Entries converts HAR entries to a slice of Entry (http.Request and http.Response pairs).
func (s *HARStorage) Entries() []*Entry {
entries := make([]*Entry, len(s.har.Log.Entries))
s.lock.Lock()
defer s.lock.Unlock()
s.lock.RLock()
defer s.lock.RUnlock()

for i, e := range s.har.Log.Entries {
postData := ""
Expand Down Expand Up @@ -220,6 +220,8 @@ func (s *HARStorage) Entries() []*Entry {

// Delete removes the HAR entry with the given ID.
func (s *HARStorage) Delete(id string) bool {
s.lock.Lock()
defer s.lock.Unlock()
for i, e := range s.har.Log.Entries {
if e.Comment == id {
s.har.Log.Entries = append(s.har.Log.Entries[:i], s.har.Log.Entries[i+1:]...)
Expand Down

0 comments on commit a6e5378

Please sign in to comment.