Home / Function/ TestColorForMethod() — gin Function Reference

TestColorForMethod() — gin Function Reference

Architecture documentation for the TestColorForMethod() function in logger_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

logger_test.go lines 287–303

func TestColorForMethod(t *testing.T) {
	colorForMethod := func(method string) string {
		p := LogFormatterParams{
			Method: method,
		}
		return p.MethodColor()
	}

	assert.Equal(t, blue, colorForMethod(http.MethodGet), "get should be blue")
	assert.Equal(t, cyan, colorForMethod(http.MethodPost), "post should be cyan")
	assert.Equal(t, yellow, colorForMethod(http.MethodPut), "put should be yellow")
	assert.Equal(t, red, colorForMethod(http.MethodDelete), "delete should be red")
	assert.Equal(t, green, colorForMethod("PATCH"), "patch should be green")
	assert.Equal(t, magenta, colorForMethod("HEAD"), "head should be magenta")
	assert.Equal(t, white, colorForMethod("OPTIONS"), "options should be white")
	assert.Equal(t, reset, colorForMethod("TRACE"), "trace is not defined and should be the reset color")
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free