diff --git a/gorush/server_test.go b/gorush/server_test.go index cb9e85b..8a52908 100644 --- a/gorush/server_test.go +++ b/gorush/server_test.go @@ -63,6 +63,17 @@ func TestRunTLSServer(t *testing.T) { gofight.TestRequest(t, "https://localhost:8087/api/stat/go") } +func TestLoadTLSCertError(t *testing.T) { + initTest() + + PushConf.Core.SSL = true + PushConf.Core.Port = "8087" + PushConf.Core.CertPath = "../config/config.yml" + PushConf.Core.KeyPath = "../config/config.yml" + + assert.Error(t, RunHTTPServer()) +} + func TestRootHandler(t *testing.T) { initTest() diff --git a/gorush/server_unix.go b/gorush/server_unix.go index 01ee10d..2a855d9 100644 --- a/gorush/server_unix.go +++ b/gorush/server_unix.go @@ -25,7 +25,8 @@ func RunHTTPServer() error { config.Certificates = make([]tls.Certificate, 1) config.Certificates[0], err = tls.LoadX509KeyPair(PushConf.Core.CertPath, PushConf.Core.KeyPath) if err != nil { - LogError.Fatal("Failed to load https cert file: ", err) + LogError.Error("Failed to load https cert file: ", err) + return err } err = gracehttp.Serve(&http.Server{