-
Notifications
You must be signed in to change notification settings - Fork 40
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
[TEST] increase test coverage of package runtime to maximum #75
Conversation
922ec8d
to
36d881b
Compare
cb62a1d
to
bb59974
Compare
webserver/webserver_test.go
Outdated
srv := New(":8080", "/tmp") | ||
assert.NotNil(srv) | ||
|
||
//TODO test panic in a go routine (HOWTO) |
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.
Please also stop the server.
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.
Closing the webserver create a panic 👎 -> so this tests fails
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.
Then fix it!
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.
44a9928
to
cb8b3de
Compare
@@ -38,7 +38,8 @@ var serveCmd = &cobra.Command{ | |||
if config.Webserver.Enable { | |||
log.Println("starting webserver on", config.Webserver.Bind) | |||
srv := webserver.New(config.Webserver.Bind, config.Webserver.Webroot) | |||
go srv.Close() | |||
go webserver.Start(srv) | |||
defer srv.Close() |
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.
Sag mal, war das ein Bug mit defer vs. go ? @corny
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.
go srv.Close()
sieht falsch aus.
@corny magstdu es dir durchschauen und ggf. squash mergen? |
assert := assert.New(t) | ||
|
||
srv := New(":8080", "/tmp") | ||
assert.NotNil(srv) |
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.
Bitte den Server Socket wieder schließen im Test!
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.
ups, stimmt, da war noch was
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.
done
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.
Das ist scheiße. Wenn der Server ordentlich beendet wird, darf es kein panic
geben!
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.
Die Lösung ist wahrscheinlich hier:
https://talks.golang.org/2017/state-of-go/stdlib/shutdown.go
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.
Ah cool, die haben die Errors als const definiert 👍
Done
assert := assert.New(t) | ||
|
||
srv := New(":8080", "/tmp") | ||
assert.NotNil(srv) |
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.
Das ist scheiße. Wenn der Server ordentlich beendet wird, darf es kein panic
geben!
webserver/webserver.go
Outdated
func Start(srv *http.Server) { | ||
// service connections | ||
if err := srv.ListenAndServe(); err != nil { | ||
if err != http.ErrServerClosed { | ||
panic(err) |
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.
ListenAndServe()
gibt niemals nil
zurück. Bitte vereinfachen.
a9dfe30
to
b72f35d
Compare
Soll ich schon mal squashen? Oder magst zum verfolgen noch die einzelnen commit haben |
b72f35d
to
5705b3d
Compare
5705b3d
to
7865ab1
Compare
No description provided.