Skip to content

Commit 266647e

Browse files
authored
Fixing testing errors (#1871)
fix: resolve failing unit tests and diff consistency in v1beta3 - Fix readLinesFromReader to return lines WITH newlines (like difflib.SplitLines) - Update test expectations to match correct function behavior with newlines - This ensures consistency between streaming and non-streaming diff paths - Fix timeout test by changing from 10ms to 500ms to eliminate flaky failures Fixes TestReadLinesFromReader and Test_loadSupportBundleSpecsFromURIs_TimeoutError Resolves diff output inconsistency between code paths
1 parent 3062dd8 commit 266647e

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

cmd/troubleshoot/cli/diff_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,14 @@ func TestReadLinesFromReader(t *testing.T) {
513513
content: "line1\nline2\nline3\n",
514514
maxBytes: 1000,
515515
wantLen: 3,
516-
wantLast: "line3",
516+
wantLast: "line3\n",
517517
},
518518
{
519519
name: "content exceeds limit",
520520
content: "line1\nline2\nline3\nline4\nline5\n",
521521
maxBytes: 15, // Only allows first 2 lines plus truncation marker
522522
wantLen: 3,
523-
wantLast: "... (content truncated due to size)",
523+
wantLast: "... (content truncated due to size)\n",
524524
},
525525
{
526526
name: "empty content",

cmd/troubleshoot/cli/run_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ func Test_loadSupportBundleSpecsFromURIs_TimeoutError(t *testing.T) {
140140
})
141141
require.NoError(t, err)
142142

143-
// Set the timeout on the http client to 10ms
143+
// Set the timeout on the http client to 500ms
144+
// The server sleeps for 2 seconds, so this should still timeout
144145
// supportbundle.LoadSupportBundleSpec does not yet use the context
145146
before := httputil.GetHttpClient().Timeout
146-
httputil.GetHttpClient().Timeout = 10 * time.Millisecond
147+
httputil.GetHttpClient().Timeout = 500 * time.Millisecond
147148
defer func() {
148149
// Reinstate the original timeout. Its a global var so we need to reset it
149150
httputil.GetHttpClient().Timeout = before

0 commit comments

Comments
 (0)