From 5d0bbdf4ade428334e129cb4b2e805fb3808d72f Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 1 Jan 2017 15:47:54 +0800 Subject: [PATCH] Add load tls file testing error. Signed-off-by: Bo-Yi Wu --- gorush/server_test.go | 11 +++++++++++ gorush/server_unix.go | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) 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{