Home / File/ logger_test.go — gin Source File

logger_test.go — gin Source File

Architecture documentation for logger_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go GinCore Middleware 1 imports 17 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  9089ba1c_3991_2941_2a87_9934a9e12a6a["logger_test.go"]
  285f3da5_b453_bac8_eb53_efea9feb6bb9["errors"]
  9089ba1c_3991_2941_2a87_9934a9e12a6a --> 285f3da5_b453_bac8_eb53_efea9feb6bb9
  style 9089ba1c_3991_2941_2a87_9934a9e12a6a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
	"errors"
	"fmt"
	"net/http"
	"strings"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func init() {
	SetMode(TestMode)
}

func TestLogger(t *testing.T) {
	buffer := new(strings.Builder)
	router := New()
	router.Use(LoggerWithWriter(buffer))
	router.GET("/example", func(c *Context) {})
	router.POST("/example", func(c *Context) {})
	router.PUT("/example", func(c *Context) {})
	router.DELETE("/example", func(c *Context) {})
	router.PATCH("/example", func(c *Context) {})
	router.HEAD("/example", func(c *Context) {})
	router.OPTIONS("/example", func(c *Context) {})

	PerformRequest(router, http.MethodGet, "/example?a=100")
	assert.Contains(t, buffer.String(), "200")
	assert.Contains(t, buffer.String(), http.MethodGet)
	assert.Contains(t, buffer.String(), "/example")
	assert.Contains(t, buffer.String(), "a=100")

	// I wrote these first (extending the above) but then realized they are more
	// like integration tests because they test the whole logging process rather
	// than individual functions. I'm not sure where these should go.
	buffer.Reset()
	PerformRequest(router, http.MethodPost, "/example")
	assert.Contains(t, buffer.String(), "200")
	assert.Contains(t, buffer.String(), http.MethodPost)
	assert.Contains(t, buffer.String(), "/example")

	buffer.Reset()
	PerformRequest(router, http.MethodPut, "/example")
	assert.Contains(t, buffer.String(), "200")
	assert.Contains(t, buffer.String(), http.MethodPut)
	assert.Contains(t, buffer.String(), "/example")

	buffer.Reset()
	PerformRequest(router, http.MethodDelete, "/example")
	assert.Contains(t, buffer.String(), "200")
	assert.Contains(t, buffer.String(), http.MethodDelete)
	assert.Contains(t, buffer.String(), "/example")

// ... (414 more lines)

Domain

Subdomains

Classes

Dependencies

  • errors

Frequently Asked Questions

What does logger_test.go do?
logger_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Middleware subdomain.
What functions are defined in logger_test.go?
logger_test.go defines 17 function(s): TestColorForLatency, TestColorForMethod, TestColorForStatus, TestDefaultLogFormatter, TestDisableConsoleColor, TestErrorLogger, TestForceConsoleColor, TestIsOutputColor, TestLogger, TestLoggerWithConfig, and 7 more.
What does logger_test.go depend on?
logger_test.go imports 1 module(s): errors.
Where is logger_test.go in the architecture?
logger_test.go is located at logger_test.go (domain: GinCore, subdomain: Middleware).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free