[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types.RequestResponse url field UnmarshalJSON bug #5267

Merged
merged 3 commits into from
Jun 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add http unmarshal json test case
  • Loading branch information
LazyMaple committed Jun 7, 2024
commit d4b27918a01601383e7b796bf5ee46505e707442
13 changes: 8 additions & 5 deletions pkg/input/types/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ func TestParseHttpRequest(t *testing.T) {

func TestUnmarshalJSON(t *testing.T) {
tests := []struct {
name string
rawJSONStr string
name string
rawJSONStr string
expectedURLStr string
}{
{"basic url", `{"url": "example.com"}`},
{"basic url with scheme", `{"url": "http://example.com"}`},
{"basic url", `{"url": "example.com"}`, "example.com"},
{"basic url with scheme", `{"url": "http://example.com"}`, "http://example.com"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -81,7 +82,9 @@ func TestUnmarshalJSON(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Logf("url: %+v", rr.URL)
if tc.expectedURLStr != "" {
require.Equal(t, rr.URL.String(), tc.expectedURLStr)
}
})
}
}
Loading