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

Function TestConfigurationYAML

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

Source from the content-addressed store, hash-verified

130}
131
132func TestConfigurationYAML(t *testing.T) {
133 yamlFile, ferr := os.CreateTemp("", "configuration.yml")
134
135 if ferr != nil {
136 t.Fatal(ferr)
137 }
138
139 defer func() {
140 yamlFile.Close()
141 time.Sleep(50 * time.Millisecond)
142 os.Remove(yamlFile.Name())
143 }()
144
145 yamlConfigurationContents := `
146DisablePathCorrection: false
147DisablePathCorrectionRedirection: true
148EnablePathIntelligence: true
149EnablePathEscape: false
150FireMethodNotAllowed: true
151EnableOptimizations: true
152DisableBodyConsumptionOnUnmarshal: true
153TimeFormat: "Mon, 02 Jan 2006 15:04:05 GMT"
154Charset: "utf-8"
155RemoteAddrHeaders:
156 - X-Real-Ip
157 - X-Forwarded-For
158 - CF-Connecting-IP
159HostProxyHeaders:
160 X-Host: true
161SSLProxyHeaders:
162 X-Forwarded-Proto: https
163Other:
164 MyServerName: "Iris: https://github.com/kataras/iris"
165`
166 yamlFile.WriteString(yamlConfigurationContents)
167 filename := yamlFile.Name()
168 app := New().Configure(WithConfiguration(YAML(filename)))
169
170 c := app.config
171
172 if expected := false; c.DisablePathCorrection != expected {
173 t.Fatalf("error on TestConfigurationYAML: Expected DisablePathCorrection %v but got %v", expected, c.DisablePathCorrection)
174 }
175
176 if expected := true; c.DisablePathCorrectionRedirection != expected {
177 t.Fatalf("error on TestConfigurationYAML: Expected DisablePathCorrectionRedirection %v but got %v", expected, c.DisablePathCorrectionRedirection)
178 }
179
180 if expected := true; c.EnablePathIntelligence != expected {
181 t.Fatalf("error on TestConfigurationYAML: Expected EnablePathIntelligence %v but got %v", expected, c.EnablePathIntelligence)
182 }
183
184 if expected := false; c.EnablePathEscape != expected {
185 t.Fatalf("error on TestConfigurationYAML: Expected EnablePathEscape %v but got %v", expected, c.EnablePathEscape)
186 }
187
188 if expected := true; c.EnableOptimizations != expected {
189 t.Fatalf("error on TestConfigurationYAML: Expected EnableOptimizations %v but got %v", expected, c.EnablePathEscape)

Callers

nothing calls this directly

Calls 10

WithConfigurationFunction · 0.85
YAMLFunction · 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…