MCPcopy Index your code
hub / github.com/kataras/iris / TestConfigurationTOML

Function TestConfigurationTOML

configuration_test.go:265–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func TestConfigurationTOML(t *testing.T) {
266 tomlFile, ferr := os.CreateTemp("", "configuration.toml")
267
268 if ferr != nil {
269 t.Fatal(ferr)
270 }
271
272 defer func() {
273 tomlFile.Close()
274 time.Sleep(50 * time.Millisecond)
275 os.Remove(tomlFile.Name())
276 }()
277
278 tomlConfigurationContents := `
279DisablePathCorrectionRedirection = true
280EnablePathEscape = false
281FireMethodNotAllowed = true
282EnableOptimizations = true
283DisableBodyConsumptionOnUnmarshal = true
284TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
285Charset = "utf-8"
286
287RemoteAddrHeaders = ["X-Real-Ip", "X-Forwarded-For", "CF-Connecting-IP"]
288
289[Other]
290 # Indentation (tabs and/or spaces) is allowed but not required
291 MyServerName = "Iris: https://github.com/kataras/iris"
292
293`
294 tomlFile.WriteString(tomlConfigurationContents)
295 filename := tomlFile.Name()
296 app := New().Configure(WithConfiguration(TOML(filename)))
297
298 c := app.config
299
300 if expected := false; c.DisablePathCorrection != expected {
301 t.Fatalf("error on TestConfigurationTOML: Expected DisablePathCorrection %v but got %v", expected, c.DisablePathCorrection)
302 }
303
304 if expected := true; c.DisablePathCorrectionRedirection != expected {
305 t.Fatalf("error on TestConfigurationTOML: Expected DisablePathCorrectionRedirection %v but got %v", expected, c.DisablePathCorrectionRedirection)
306 }
307
308 if expected := false; c.EnablePathEscape != expected {
309 t.Fatalf("error on TestConfigurationTOML: Expected EnablePathEscape %v but got %v", expected, c.EnablePathEscape)
310 }
311
312 if expected := true; c.EnableOptimizations != expected {
313 t.Fatalf("error on TestConfigurationTOML: Expected EnableOptimizations %v but got %v", expected, c.EnablePathEscape)
314 }
315
316 if expected := true; c.FireMethodNotAllowed != expected {
317 t.Fatalf("error on TestConfigurationTOML: Expected FireMethodNotAllowed %v but got %v", expected, c.FireMethodNotAllowed)
318 }
319
320 if expected := true; c.DisableBodyConsumptionOnUnmarshal != expected {
321 t.Fatalf("error on TestConfigurationTOML: Expected DisableBodyConsumptionOnUnmarshal %v but got %v", expected, c.DisableBodyConsumptionOnUnmarshal)
322 }

Callers

nothing calls this directly

Calls 10

WithConfigurationFunction · 0.85
TOMLFunction · 0.85
FatalMethod · 0.80
RemoveMethod · 0.80
WriteStringMethod · 0.80
FatalfMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.65
ConfigureMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…