I've checked the documentation but it does not explain the use of setting test mode for gin
gin.SetMode(gin.TestMode)
What is this test mode provided for? I do not see any difference when setting & not setting this mode in my tests.
I've checked the documentation but it does not explain the use of setting test mode for gin
gin.SetMode(gin.TestMode)
What is this test mode provided for? I do not see any difference when setting & not setting this mode in my tests.
Copyright © 2021 Jogjafile Inc.
The flag
gin.DebugMode
is used to control the output ofgin.IsDebugging()
, which adds some additional log output and changes the HTML renderer to the debug structHTMLDebug
.The
gin.TestMode
is used in Gin's own unit tests to toggle the debug mode (and the additional logging) on and off, and the usage of the debug HTML renderer.Other than that, it doesn't have other uses (source).
However, the flag can be controlled with the environment variable
GIN_MODE=test
. Then, sinceMode()
is exported, you can use it in application code to, for example, declare testing routes. This might have some merit if you plan to run an E2E test suite, or some other integration test: