Skip to content

Commit 8b28bf8

Browse files
BenjaminKazemicopybara-github
authored andcommitted
chore: Throw fatals() instead of errors() in the replay_api_client when the issue is a test infra
PiperOrigin-RevId: 915514937
1 parent c02ba4f commit 8b28bf8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

replay_api_client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (rac *replayAPIClient) LoadReplay(replayFilePath string) {
8787
}
8888
var replayFile replayFile
8989
if err := readFileForReplayTest(fullReplaysPath, &replayFile, true); err != nil {
90-
rac.t.Errorf("error loading replay file, %v", err)
90+
rac.t.Fatalf("error loading replay file, %v", err)
9191
}
9292
rac.ReplayFile = &replayFile
9393
}
@@ -133,7 +133,7 @@ func (rac *replayAPIClient) ServeHTTP(w http.ResponseWriter, req *http.Request)
133133
for i := 0; i < len(interaction.Response.BodySegments); i++ {
134134
responseBodySegment, err := json.Marshal(interaction.Response.BodySegments[i])
135135
if err != nil {
136-
rac.t.Errorf("error marshalling responseBodySegment [%s], err: %+v", rac.ReplayFile.ReplayID, err)
136+
rac.t.Fatalf("error marshalling responseBodySegment [%s], err: %+v", rac.ReplayFile.ReplayID, err)
137137
}
138138
bodySegments = append(bodySegments, string(responseBodySegment))
139139
}
@@ -144,7 +144,7 @@ func (rac *replayAPIClient) ServeHTTP(w http.ResponseWriter, req *http.Request)
144144
}
145145
_, err := w.Write([]byte(strings.Join(bodySegments, "\n")))
146146
if err != nil {
147-
rac.t.Errorf("error writing response, err: %+v", err)
147+
rac.t.Fatalf("error writing response, err: %+v", err)
148148
}
149149
}
150150

@@ -258,12 +258,12 @@ func (rac *replayAPIClient) assertRequest(sdkRequest *http.Request, replayReques
258258
rac.t.Helper()
259259
sdkRequestBody, err := io.ReadAll(sdkRequest.Body)
260260
if err != nil {
261-
rac.t.Errorf("Error reading request body, err: %+v", err)
261+
rac.t.Fatalf("Error reading request body, err: %+v", err)
262262
}
263263
bodySegment := make(map[string]any)
264264
if len(sdkRequestBody) > 0 {
265265
if err := json.Unmarshal(sdkRequestBody, &bodySegment); err != nil {
266-
rac.t.Errorf("Error unmarshalling body, err: %+v", err)
266+
rac.t.Fatalf("Error unmarshalling body, err: %+v", err)
267267
}
268268
}
269269
bodySegment = redactRequestBody(bodySegment)

0 commit comments

Comments
 (0)