@@ -164,6 +164,14 @@ func TestRecordOnlyMode(t *testing.T) {
164
164
t .Fatal ("recorder is not in the correct mode" )
165
165
}
166
166
167
+ if rec .IsRecording () != true {
168
+ t .Fatal ("recorder is not recording" )
169
+ }
170
+
171
+ if ! rec .IsNewCassette () {
172
+ t .Fatal ("recorder is not using a new cassette" )
173
+ }
174
+
167
175
// Run tests
168
176
ctx := context .Background ()
169
177
client := rec .GetDefaultClient ()
@@ -254,6 +262,10 @@ func TestReplayWithContextTimeout(t *testing.T) {
254
262
t .Fatal ("recorder is not in the correct mode" )
255
263
}
256
264
265
+ if rec .IsRecording () != true {
266
+ t .Fatal ("recorder is not recording" )
267
+ }
268
+
257
269
tests := []testCase {
258
270
{
259
271
method : http .MethodGet ,
@@ -294,6 +306,11 @@ func TestReplayWithContextTimeout(t *testing.T) {
294
306
t .Fatal ("recorder is not in the correct mode" )
295
307
}
296
308
309
+ // This time the recording should only be replaying
310
+ if rec .IsRecording () != false {
311
+ t .Fatal ("recorder should not be recording" )
312
+ }
313
+
297
314
defer rec .Stop ()
298
315
client = rec .GetDefaultClient ()
299
316
@@ -340,6 +357,10 @@ func TestRecordOnceWithMissingEpisodes(t *testing.T) {
340
357
t .Fatal (err )
341
358
}
342
359
360
+ if rec .IsRecording () != true {
361
+ t .Fatal ("recorder is not recording" )
362
+ }
363
+
343
364
if rec .Mode () != recorder .ModeRecordOnce {
344
365
t .Fatal ("recorder is not in the correct mode" )
345
366
}
@@ -367,6 +388,10 @@ func TestRecordOnceWithMissingEpisodes(t *testing.T) {
367
388
t .Fatal ("recorder is not in the correct mode" )
368
389
}
369
390
391
+ if rec .IsRecording () != false {
392
+ t .Fatal ("recorder should not be recording" )
393
+ }
394
+
370
395
newTests := []testCase {
371
396
{
372
397
method : http .MethodHead ,
@@ -436,6 +461,10 @@ func TestReplayWithNewEpisodes(t *testing.T) {
436
461
t .Fatal (err )
437
462
}
438
463
464
+ if rec .IsRecording () != true {
465
+ t .Fatal ("recorder is not recording" )
466
+ }
467
+
439
468
if rec .Mode () != recorder .ModeReplayWithNewEpisodes {
440
469
t .Fatal ("recorder is not in the correct mode" )
441
470
}
@@ -522,6 +551,7 @@ func TestPassthroughMode(t *testing.T) {
522
551
523
552
server := newEchoHttpServer ()
524
553
serverUrl := server .URL
554
+ defer server .Close ()
525
555
526
556
cassPath , err := newCassettePath ("test_passthrough_mode" )
527
557
if err != nil {
@@ -536,12 +566,15 @@ func TestPassthroughMode(t *testing.T) {
536
566
if err != nil {
537
567
t .Fatal (err )
538
568
}
539
- defer server .Close ()
540
569
541
570
if m := rec .Mode (); m != recorder .ModePassthrough {
542
571
t .Fatal ("recorder is not in the correct mode" )
543
572
}
544
573
574
+ if rec .IsRecording () != false {
575
+ t .Fatal ("recorder should not be recording" )
576
+ }
577
+
545
578
// Run tests
546
579
ctx := context .Background ()
547
580
client := rec .GetDefaultClient ()
@@ -602,6 +635,10 @@ func TestPassthroughHandler(t *testing.T) {
602
635
t .Fatal ("recorder is not in the correct mode" )
603
636
}
604
637
638
+ if rec .IsRecording () != true {
639
+ t .Fatal ("recorder is not recording" )
640
+ }
641
+
605
642
// Add a passthrough handler which does not record any
606
643
// requests with a specific body.
607
644
rec .AddPassthrough (func (r * http.Request ) bool {
@@ -687,6 +724,10 @@ func TestFilter(t *testing.T) {
687
724
t .Fatal ("recorder is not in the correct mode" )
688
725
}
689
726
727
+ if rec .IsRecording () != true {
728
+ t .Fatal ("recorder is not recording" )
729
+ }
730
+
690
731
// Add a filter which replaces each request body in the stored
691
732
// cassette:
692
733
dummyBody := "[REDACTED]"
@@ -759,6 +800,10 @@ func TestPreSaveFilter(t *testing.T) {
759
800
t .Fatal ("recorder is not in the correct mode" )
760
801
}
761
802
803
+ if rec .IsRecording () != true {
804
+ t .Fatal ("recorder is not recording" )
805
+ }
806
+
762
807
// Add a save filter which replaces each request body in the stored cassette
763
808
dummyBody := "[REDACTED]"
764
809
rec .AddPreSaveFilter (func (i * cassette.Interaction ) error {
@@ -824,6 +869,10 @@ func TestReplayableInteractions(t *testing.T) {
824
869
t .Fatal ("recorder is not in the correct mode" )
825
870
}
826
871
872
+ if rec .IsRecording () != true {
873
+ t .Fatal ("recorder is not recording" )
874
+ }
875
+
827
876
// Configure replayable interactions
828
877
rec .SetReplayableInteractions (true )
829
878
@@ -889,6 +938,10 @@ func TestWithCustomMatcher(t *testing.T) {
889
938
t .Fatal ("recorder is not in the correct mode" )
890
939
}
891
940
941
+ if rec .IsRecording () != true {
942
+ t .Fatal ("recorder is not recording" )
943
+ }
944
+
892
945
// Run tests first in RecordOnce mode, so we capture the
893
946
// interactions
894
947
ctx := context .Background ()
@@ -922,6 +975,10 @@ func TestWithCustomMatcher(t *testing.T) {
922
975
t .Fatal ("recorder is not in the correct mode" )
923
976
}
924
977
978
+ if rec .IsRecording () != false {
979
+ t .Fatal ("recorder should not be recording" )
980
+ }
981
+
925
982
// Set replayable interactions to true, so that we can match
926
983
// against the already recorded interactions.
927
984
rec .SetReplayableInteractions (true )
0 commit comments