Home / Function/ TestColorForLatency() — gin Function Reference

TestColorForLatency() — gin Function Reference

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

Entity Profile

Relationship Graph

Source Code

logger_test.go lines 320–335

func TestColorForLatency(t *testing.T) {
	colorForLantency := func(latency time.Duration) string {
		p := LogFormatterParams{
			Latency: latency,
		}
		return p.LatencyColor()
	}

	assert.Equal(t, white, colorForLantency(time.Duration(0)), "0 should be white")
	assert.Equal(t, white, colorForLantency(time.Millisecond*20), "20ms should be white")
	assert.Equal(t, green, colorForLantency(time.Millisecond*150), "150ms should be green")
	assert.Equal(t, cyan, colorForLantency(time.Millisecond*250), "250ms should be cyan")
	assert.Equal(t, yellow, colorForLantency(time.Millisecond*600), "600ms should be yellow")
	assert.Equal(t, magenta, colorForLantency(time.Millisecond*1500), "1.5s should be magenta")
	assert.Equal(t, red, colorForLantency(time.Second*3), "other things should be red")
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free