From 2eb4b2d876a929c79d7620ef81a895f351e54d65 Mon Sep 17 00:00:00 2001 From: Benjamen Meyer Date: Sun, 4 Dec 2022 23:22:16 -0500 Subject: [PATCH] Bug Fix: golangci-linter checks --- Makefile | 3 +++ common/call_test.go | 4 ++-- common/reply_test.go | 4 ++-- router/router_test.go | 2 +- service/service_test.go | 10 ++++++++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b1b456d..eadfc68 100644 --- a/Makefile +++ b/Makefile @@ -7,3 +7,6 @@ test: coverage: test go tool cover -html=.coverage go tool cover -func=.coverage + +lint: + golangci-lint run diff --git a/common/call_test.go b/common/call_test.go index d7abc60..aee8106 100644 --- a/common/call_test.go +++ b/common/call_test.go @@ -15,7 +15,7 @@ func Test_Common_HttpCall(t *testing.T) { Headers: http.Header{}, Request: &http.Request{}, } - if hc == nil { - t.Error("Unexpected nil") + if hc.Method != "test" { + t.Errorf("Failed to set method") } } diff --git a/common/reply_test.go b/common/reply_test.go index 1d37822..b6e1a99 100644 --- a/common/reply_test.go +++ b/common/reply_test.go @@ -12,7 +12,7 @@ func Test_Common_HttpReply(t *testing.T) { Status: common.HttpStatus_RouteNotHandled, Headers: http.Header{}, } - if hr == nil { - t.Error("Unexpected nil") + if hr.Status != common.HttpStatus_RouteNotHandled { + t.Errorf("Failed to set Status") } } diff --git a/router/router_test.go b/router/router_test.go index bfeee73..4768a70 100644 --- a/router/router_test.go +++ b/router/router_test.go @@ -59,7 +59,7 @@ func Test_Router_Router(t *testing.T) { func(t *testing.T) { irt := router.New() if irt == nil { - t.Errorf("New generated a nil pointer") + t.Fatal("New generated a nil pointer") } if irt.RequestHandlers == nil { t.Errorf("New did not create the route table") diff --git a/service/service_test.go b/service/service_test.go index fddd658..13be5f0 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -90,10 +90,13 @@ func TestService(t *testing.T) { scenario.name, func(t *testing.T) { handler := service.ServiceHandler{} - handler.Init( + initErr := handler.Init( scenario.name, &common.BasicServerURI{}, ) + if initErr != nil { + t.Errorf("Failed to initialize the service handler: %#v", initErr) + } parameters := scenario.setup(t) @@ -157,13 +160,16 @@ func TestService(t *testing.T) { scenario.name, func(t *testing.T) { handler := service.ServiceHandler{} - handler.Init( + initErr := handler.Init( scenario.name, &common.BasicServerURI{ Protocol: "http", Host: "example.com", }, ) + if initErr != nil { + t.Errorf("Failed to initialize the service handler: %#v", initErr) + } parameters := scenario.setup(t)