From 23afedf81b3873bac08f60ceb4ed36404f4c44b4 Mon Sep 17 00:00:00 2001 From: "J. Yi" <93548144+jyyi1@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:42:57 -0500 Subject: [PATCH] fix(client): update fetch tests after refactoring (#2300) --- client/go/outline/fetch_test.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/client/go/outline/fetch_test.go b/client/go/outline/fetch_test.go index 5ad000e151..703b376a3b 100644 --- a/client/go/outline/fetch_test.go +++ b/client/go/outline/fetch_test.go @@ -30,9 +30,9 @@ func TestFetchResource(t *testing.T) { })) defer server.Close() - result := fetchResource(server.URL) - require.Nil(t, result.Error) - require.Equal(t, "{\"name\": \"my-test-key\"}\n", result.Content) + content, err := fetchResource(server.URL) + require.Nil(t, err) + require.Equal(t, "{\"name\": \"my-test-key\"}\n", content) } func TestFetchResource_Redirection(t *testing.T) { @@ -55,9 +55,9 @@ func TestFetchResource_Redirection(t *testing.T) { })) defer redirSvr.Close() - result := fetchResource(redirSvr.URL) - require.Nil(t, result.Error) - require.Equal(t, "ss://my-url-format-test-key\n", result.Content) + content, err := fetchResource(redirSvr.URL) + require.Nil(t, err) + require.Equal(t, "ss://my-url-format-test-key\n", content) } } @@ -78,10 +78,12 @@ func TestFetchResource_HTTPStatusError(t *testing.T) { })) defer server.Close() - result := fetchResource(server.URL) - require.Error(t, result.Error) - require.Equal(t, platerrors.FetchConfigFailed, result.Error.Code) - require.Error(t, result.Error.Cause) + var perr platerrors.PlatformError + content, err := fetchResource(server.URL) + require.Empty(t, content) + require.ErrorAs(t, err, &perr) + require.Equal(t, platerrors.FetchConfigFailed, perr.Code) + require.Error(t, perr.Cause) } } @@ -91,8 +93,10 @@ func TestFetchResource_BodyReadError(t *testing.T) { })) defer server.Close() - result := fetchResource(server.URL) - require.Error(t, result.Error) - require.Equal(t, platerrors.FetchConfigFailed, result.Error.Code) - require.Error(t, result.Error.Cause) + var perr platerrors.PlatformError + content, err := fetchResource(server.URL) + require.Empty(t, content) + require.ErrorAs(t, err, &perr) + require.Equal(t, platerrors.FetchConfigFailed, perr.Code) + require.Error(t, perr.Cause) }