Skip to content

Commit

Permalink
Merge branch 'master' into junyi/modern-linux-routing
Browse files Browse the repository at this point in the history
  • Loading branch information
jyyi1 authored Dec 6, 2024
2 parents 0dede89 + 23afedf commit 47bf530
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions client/go/outline/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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)
}

0 comments on commit 47bf530

Please sign in to comment.