From 2e44c58e4f17c922408912b57ad97bc1d2d5f532 Mon Sep 17 00:00:00 2001 From: xiantang Date: Sun, 19 Jan 2025 16:18:07 +0800 Subject: [PATCH] fix TestProxy_injectLiveReload test case failed --- runner/proxy_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/runner/proxy_test.go b/runner/proxy_test.go index b951919d..de8e580b 100644 --- a/runner/proxy_test.go +++ b/runner/proxy_test.go @@ -202,7 +202,7 @@ func TestProxy_injectLiveReload(t *testing.T) { }, Body: io.NopCloser(strings.NewReader(`

test

`)), }, - expect: `

test

`, + expect: fmt.Sprintf(`

test

`, ProxyScript), }, } for _, tt := range tests { @@ -212,8 +212,15 @@ func TestProxy_injectLiveReload(t *testing.T) { ProxyPort: 1111, AppPort: 2222, }) - if got, _ := proxy.injectLiveReload(tt.given); got != tt.expect { - t.Errorf("expected page %+v, got %v", tt.expect, got) + got, _ := proxy.injectLiveReload(tt.given) + if got != tt.expect { + // Use a more descriptive error message + if len(got) > 100 || len(tt.expect) > 100 { + t.Errorf("Script injection mismatch.\nGot length: %d\nExpected length: %d", + len(got), len(tt.expect)) + } else { + t.Errorf("expected page %+v, got %v", tt.expect, got) + } } }) }