-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable switching a decrypted cassette to encryption mode (#78)
Also, increase test coverage
- Loading branch information
Showing
7 changed files
with
217 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package track | ||
|
||
import ( | ||
"net/url" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_cloneURLValues(t *testing.T) { | ||
unit := url.Values{ | ||
"one": { | ||
"one.1", "one.2", | ||
}, | ||
"two": { | ||
"two.1", "", | ||
}, | ||
"three": {}, | ||
} | ||
|
||
got := cloneURLValues(unit) | ||
assert.Equal(t, unit, got) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package govcr | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/seborama/govcr/v8/cassette/track" | ||
) | ||
|
||
func TestControlPanel_SetRecordingMutators(t *testing.T) { | ||
unit := &ControlPanel{ | ||
client: &http.Client{ | ||
Transport: &vcrTransport{ | ||
pcb: &PrintedCircuitBoard{ | ||
trackRecordingMutators: track.Mutators{ | ||
track.TrackRequestAddHeaderValue("k", "v"), | ||
track.TrackRequestDeleteHeaderKeys("k2"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
unit.SetRecordingMutators(track.TrackRequestDeleteHeaderKeys("k1")) | ||
|
||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackRecordingMutators, 1) | ||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackReplayingMutators, 0) | ||
} | ||
|
||
func TestControlPanel_AddRecordingMutators(t *testing.T) { | ||
unit := &ControlPanel{ | ||
client: &http.Client{ | ||
Transport: &vcrTransport{ | ||
pcb: &PrintedCircuitBoard{ | ||
trackRecordingMutators: track.Mutators{ | ||
track.TrackRequestAddHeaderValue("k", "v"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
unit.AddRecordingMutators(track.TrackRequestDeleteHeaderKeys("k2")) | ||
|
||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackRecordingMutators, 2) | ||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackReplayingMutators, 0) | ||
} | ||
|
||
func TestControlPanel_SetReplayingMutators(t *testing.T) { | ||
unit := &ControlPanel{ | ||
client: &http.Client{ | ||
Transport: &vcrTransport{ | ||
pcb: &PrintedCircuitBoard{ | ||
trackReplayingMutators: track.Mutators{ | ||
track.TrackRequestAddHeaderValue("k", "v"), | ||
track.TrackRequestDeleteHeaderKeys("k2"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
unit.SetReplayingMutators(track.TrackRequestDeleteHeaderKeys("k1")) | ||
|
||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackReplayingMutators, 1) | ||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackRecordingMutators, 0) | ||
} | ||
|
||
func TestControlPanel_AddReplayingMutators(t *testing.T) { | ||
unit := &ControlPanel{ | ||
client: &http.Client{ | ||
Transport: &vcrTransport{ | ||
pcb: &PrintedCircuitBoard{ | ||
trackReplayingMutators: track.Mutators{ | ||
track.TrackRequestAddHeaderValue("k", "v"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
unit.AddReplayingMutators(track.TrackRequestDeleteHeaderKeys("k2")) | ||
|
||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackReplayingMutators, 2) | ||
assert.Len(t, unit.client.Transport.(*vcrTransport).pcb.trackRecordingMutators, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package govcr | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWithLiveOnlyMode(t *testing.T) { | ||
vcrSettings := &VCRSettings{} | ||
|
||
WithLiveOnlyMode()(vcrSettings) | ||
assert.Equal(t, HTTPModeLiveOnly, vcrSettings.httpMode) | ||
} | ||
|
||
func TestWithOfflineMode(t *testing.T) { | ||
vcrSettings := &VCRSettings{} | ||
|
||
WithOfflineMode()(vcrSettings) | ||
assert.Equal(t, HTTPModeOffline, vcrSettings.httpMode) | ||
} | ||
|
||
func TestW(t *testing.T) { | ||
vcrSettings := &VCRSettings{} | ||
|
||
WithReadOnlyMode()(vcrSettings) | ||
assert.True(t, vcrSettings.readOnly) | ||
} |