From 1bfc72d6a3d8dfce7cc5993142fd6967133620a4 Mon Sep 17 00:00:00 2001 From: Zeni Kim Date: Mon, 16 Sep 2024 16:01:44 -0500 Subject: [PATCH] change hooks --- controller.go | 1 - hooks.go | 1 - hooks_test.go | 42 +++++++++++++++++++++--------------------- router_test.go | 1 - 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/controller.go b/controller.go index 71b44b1..d04d7f9 100644 --- a/controller.go +++ b/controller.go @@ -1,4 +1,3 @@ -// Copyright 2021 Harran Ali . All rights reserved. // Copyright (c) 2024 Zeni Kim // Use of this source code is governed by MIT-style // license that can be found in the LICENSE file. diff --git a/hooks.go b/hooks.go index 92798da..9294fd4 100644 --- a/hooks.go +++ b/hooks.go @@ -1,4 +1,3 @@ -// Copyright 2021 Harran Ali . All rights reserved. // Copyright (c) 2024 Zeni Kim // Use of this source code is governed by MIT-style // license that can be found in the LICENSE file. diff --git a/hooks_test.go b/hooks_test.go index ef43264..114e467 100644 --- a/hooks_test.go +++ b/hooks_test.go @@ -11,51 +11,51 @@ import ( "testing" ) -func TestNewMiddlewares(t *testing.T) { - mw := NewMiddlewares() - if fmt.Sprintf("%T", mw) != "*core.Middlewares" { - t.Errorf("failed testing new middleware") +func TestNewHooks(t *testing.T) { + mw := NewHooks() + if fmt.Sprintf("%T", mw) != "*core.Hooks" { + t.Errorf("failed testing new hook") } } -func TestResloveMiddleWares(t *testing.T) { - NewMiddlewares() - mw := ResolveMiddlewares() - if fmt.Sprintf("%T", mw) != "*core.Middlewares" { - t.Errorf("failed resolve middlewares") +func TestResloveHooks(t *testing.T) { + NewHooks() + mw := ResolveHooks() + if fmt.Sprintf("%T", mw) != "*core.Hooks" { + t.Errorf("failed resolve hooks") } } func TestAttach(t *testing.T) { - mw := NewMiddlewares() - tmw := Middleware(func(c *Context) { + mw := NewHooks() + tmw := Hook(func(c *Context) { c.GetLogger().Info("Testing!") }) mw.Attach(tmw) mws := mw.getByIndex(0) if reflect.ValueOf(tmw).Pointer() != reflect.ValueOf(mws).Pointer() { - t.Errorf("Failed testing attach middleware") + t.Errorf("Failed testing attach hook") } } -func TestGetMiddleWares(t *testing.T) { - mw := NewMiddlewares() - t1 := Middleware(func(c *Context) { +func TestGetHooks(t *testing.T) { + mw := NewHooks() + t1 := Hook(func(c *Context) { c.GetLogger().Info("testing1!") }) - t2 := Middleware(func(c *Context) { + t2 := Hook(func(c *Context) { c.GetLogger().Info("testing2!") }) mw.Attach(t1) mw.Attach(t2) - if len(mw.GetMiddlewares()) != 2 { - t.Errorf("failed testing get middlewares") + if len(mw.GetHooks()) != 2 { + t.Errorf("failed testing get hooks") } } -func TestMiddlewareGetByIndex(t *testing.T) { - mw := NewMiddlewares() - t1 := Middleware(func(c *Context) { +func TestHookGetByIndex(t *testing.T) { + mw := NewHooks() + t1 := Hook(func(c *Context) { c.GetLogger().Info("testing!") }) mw.Attach(t1) diff --git a/router_test.go b/router_test.go index 12e7775..478192c 100644 --- a/router_test.go +++ b/router_test.go @@ -1,4 +1,3 @@ -// Copyright 2021 Harran Ali . All rights reserved. // Copyright (c) 2024 Zeni Kim // Use of this source code is governed by MIT-style // license that can be found in the LICENSE file.