From 32b92611a70fe6304a61de43689ba4d47a412218 Mon Sep 17 00:00:00 2001 From: Paramtamtam <7326800+tarampampam@users.noreply.github.com> Date: Mon, 31 Jan 2022 13:44:21 +0500 Subject: [PATCH] small fixes --- internal/http/server.go | 3 +-- internal/tpl/properties_test.go | 20 ++++++++++++++++++++ internal/tpl/render.go | 1 - 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/http/server.go b/internal/http/server.go index aeacc08..2e2ff4f 100644 --- a/internal/http/server.go +++ b/internal/http/server.go @@ -4,8 +4,6 @@ import ( "strconv" "time" - "github.com/tarampampam/error-pages/internal/tpl" - "github.com/fasthttp/router" "github.com/tarampampam/error-pages/internal/checkers" "github.com/tarampampam/error-pages/internal/config" @@ -17,6 +15,7 @@ import ( notfoundHandler "github.com/tarampampam/error-pages/internal/http/handlers/notfound" versionHandler "github.com/tarampampam/error-pages/internal/http/handlers/version" "github.com/tarampampam/error-pages/internal/metrics" + "github.com/tarampampam/error-pages/internal/tpl" "github.com/tarampampam/error-pages/internal/version" "github.com/valyala/fasthttp" "go.uber.org/zap" diff --git a/internal/tpl/properties_test.go b/internal/tpl/properties_test.go index e0b6f62..9354c8b 100644 --- a/internal/tpl/properties_test.go +++ b/internal/tpl/properties_test.go @@ -44,3 +44,23 @@ func TestProperties_Replaces(t *testing.T) { assert.Equal(t, "", r["message"]) assert.Equal(t, "", r["description"]) } + +func TestProperties_Hash(t *testing.T) { + props1 := tpl.Properties{Code: "123"} + props2 := tpl.Properties{Code: "123"} + + hash1, err := props1.Hash() + assert.NoError(t, err) + + hash2, err := props2.Hash() + assert.NoError(t, err) + + assert.Equal(t, hash1, hash2) + + props2.Code = "321" + + hash2, err = props2.Hash() + assert.NoError(t, err) + + assert.NotEqual(t, hash1, hash2) +} diff --git a/internal/tpl/render.go b/internal/tpl/render.go index 1d513de..821cb6d 100644 --- a/internal/tpl/render.go +++ b/internal/tpl/render.go @@ -10,7 +10,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/tarampampam/error-pages/internal/version" )