@@ -205,7 +205,6 @@ func rewriteTextEvents(events []sessionEvent, kind, recorded, actual string,
205205 }
206206
207207 if normalizedEqual && textEventsMatch (events , kind , replacement ) {
208-
209208 return events , changed , nil
210209 }
211210
@@ -221,6 +220,7 @@ func rewriteTextEvents(events []sessionEvent, kind, recorded, actual string,
221220// stream.
222221func canonicalTextEvents (events []sessionEvent , kind string , chunks []string ,
223222 combined string ) ([]sessionEvent , error ) {
223+
224224 indices := textEventIndices (events , kind )
225225 replacement := replacementTextChunks (chunks , combined )
226226 if len (indices ) != len (replacement ) {
@@ -253,6 +253,7 @@ func replaceTextEvents(events []sessionEvent, kind string,
253253// event stream.
254254func replaceTextEventsWithCanonical (events []sessionEvent , kind string ,
255255 indices []int , replacements []sessionEvent ) ([]sessionEvent , error ) {
256+
256257 if len (indices ) == len (replacements ) {
257258 updated := append ([]sessionEvent (nil ), events ... )
258259 for i , idx := range indices {
@@ -458,15 +459,10 @@ func cloneOptionalString(value *string) *string {
458459
459460// TestUpdateRecordedSessionsEnabled verifies update-mode env parsing.
460461func TestUpdateRecordedSessionsEnabled (t * testing.T ) {
461- prev , hadPrev := os .LookupEnv (updateRecordedSessionsEnvVar )
462- if hadPrev {
463- defer func () {
464- _ = os .Setenv (updateRecordedSessionsEnvVar , prev )
465- }()
462+ if current , ok := os .LookupEnv (updateRecordedSessionsEnvVar ); ok {
463+ t .Setenv (updateRecordedSessionsEnvVar , current )
466464 } else {
467- defer func () {
468- _ = os .Unsetenv (updateRecordedSessionsEnvVar )
469- }()
465+ t .Setenv (updateRecordedSessionsEnvVar , "" )
470466 }
471467
472468 _ = os .Unsetenv (updateRecordedSessionsEnvVar )
@@ -475,12 +471,12 @@ func TestUpdateRecordedSessionsEnabled(t *testing.T) {
475471 require .NoError (t , err )
476472 require .False (t , enabled )
477473
478- require . NoError ( t , os .Setenv (updateRecordedSessionsEnvVar , "true" ) )
474+ t .Setenv (updateRecordedSessionsEnvVar , "true" )
479475 enabled , err = updateRecordedSessionsEnabled ()
480476 require .NoError (t , err )
481477 require .True (t , enabled )
482478
483- require . NoError ( t , os .Setenv (updateRecordedSessionsEnvVar , "invalid" ) )
479+ t .Setenv (updateRecordedSessionsEnvVar , "invalid" )
484480 enabled , err = updateRecordedSessionsEnabled ()
485481 require .False (t , enabled )
486482 require .EqualError (t , err ,
0 commit comments