-
Notifications
You must be signed in to change notification settings - Fork 21
Fix listener config migration #148
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -485,17 +485,18 @@ func main() { | |
| app := fiber.New(fiber.Config{ | ||
| Prefork: true, | ||
| Network: "tcp", | ||
| DisableStartupMessage: true, | ||
| EnablePrintRoutes: true, | ||
| }) | ||
| _ = app | ||
| app.Listen(":3000") | ||
| }`) | ||
|
|
||
| var buf bytes.Buffer | ||
| cmd := newCmd(&buf) | ||
| require.NoError(t, v3.MigrateConfigListenerFields(cmd, dir, nil, nil)) | ||
|
|
||
| content := readFile(t, file) | ||
| assert.Contains(t, content, "EnablePrefork: true") | ||
| assert.Contains(t, content, "ListenerNetwork: \"tcp\"") | ||
| assert.Contains(t, content, "fiber.ListenConfig{EnablePrefork: true, ListenerNetwork: \"tcp\", DisableStartupMessage: true, EnablePrintRoutes: true}") | ||
| assert.Contains(t, buf.String(), "Migrating listener related config fields") | ||
| } | ||
|
Comment on lines
496
to
501
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test coverage for
Adding these tests would help prevent regressions and ensure the migration handles more edge cases correctly. |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for injecting the moved listener configuration fields is incomplete. It only handles
app.Listencalls with a single argument and does not modify calls that already include afiber.ListenConfig. This can lead to an incorrect migration where configuration is lost if aListenConfigis already present.To make the migration more robust, it should handle both cases: adding a new
ListenConfigand injecting fields into an existing one.