-
-
Notifications
You must be signed in to change notification settings - Fork 175
Fix: getResponseHeaders() returns empty struct after setup() #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -591,6 +591,25 @@ component extends="coldbox.system.testing.BaseModelTest" { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event.setHTTPHeader( name = "expires", value = "#now()#" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function testMockRequestContextPopulatesResponseHeaders(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MockRequestContext.setHTTPHeader() should populate variables.responseHeaders | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // so that getResponseHeaders() works correctly in integration tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockEvent.init( properties = props, controller = mockController ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set custom headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mockEvent.setHTTPHeader( name = "cached-data", value = "false" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // getResponseHeaders() should return the headers that were set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var headers = mockEvent.getResponseHeaders(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( headers ).toHaveKey( "x-custom-header" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( headers[ "x-custom-header" ] ).toBe( "test-value" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( headers ).toHaveKey( "cached-data" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( headers[ "cached-data" ] ).toBe( "false" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+594
to
+611
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function testMockRequestContextPopulatesResponseHeaders(){ | |
| // MockRequestContext.setHTTPHeader() should populate variables.responseHeaders | |
| // so that getResponseHeaders() works correctly in integration tests | |
| var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" ); | |
| mockEvent.init( properties = props, controller = mockController ); | |
| // Set custom headers | |
| mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" ); | |
| mockEvent.setHTTPHeader( name = "cached-data", value = "false" ); | |
| // getResponseHeaders() should return the headers that were set | |
| var headers = mockEvent.getResponseHeaders(); | |
| expect( headers ).toHaveKey( "x-custom-header" ); | |
| expect( headers[ "x-custom-header" ] ).toBe( "test-value" ); | |
| expect( headers ).toHaveKey( "cached-data" ); | |
| expect( headers[ "cached-data" ] ).toBe( "false" ); | |
| } | |
| function testMockRequestContextPopulatesResponseHeaders(){ | |
| // MockRequestContext.setHTTPHeader() should populate variables.responseHeaders | |
| // so that getResponseHeaders() works correctly in integration tests | |
| var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" ); | |
| mockEvent.init( properties = props, controller = mockController ); | |
| // Set custom headers | |
| mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" ); | |
| mockEvent.setHTTPHeader( name = "cached-data", value = "false" ); | |
| // getResponseHeaders() should return the headers that were set | |
| var headers = mockEvent.getResponseHeaders(); | |
| expect( headers ).toHaveKey( "x-custom-header" ); | |
| expect( headers[ "x-custom-header" ] ).toBe( "test-value" ); | |
| expect( headers ).toHaveKey( "cached-data" ); | |
| expect( headers[ "cached-data" ] ).toBe( "false" ); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment line uses space indentation instead of tabs. According to the project's .cfformat.json configuration, "tab_indent": true, all indentation should use tabs, not spaces. Please update the indentation to use tabs to match the project's formatting standards.