Skip to content
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

test: add headerslist copy check #3156

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,13 @@

// https://github.com/nodejs/undici/issues/2445
test('Clone the set-cookie header when Request is passed as the first parameter and no header is passed.', (t) => {
const { strictEqual } = tspl(t, { plan: 2 })
const request = new Request('http://localhost', { headers: { 'set-cookie': 'A' } })
const request2 = new Request(request)
assert.strictDeepEqual([...request.headers], [['set-cookie', 'A']])

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest) / Test with Node.js 18 on ubuntu-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:203:9) at Test.run (node:internal/test_runner/test:631:25) at Test.processPendingSubtests (node:internal/test_runner/test:374:18) at Test.postRun (node:internal/test_runner/test:715:19) at Test.run (node:internal/test_runner/test:673:12) at async Test.processPendingSubtests (node:internal/test_runner/test:374:7), code: 'ERR_TEST_FAILURE' }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (20, ubuntu-latest) / Test with Node.js 20 on ubuntu-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (21, ubuntu-latest) / Test with Node.js 21 on ubuntu-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (21, macos-latest) / Test with Node.js 21 on macos-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/Users/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (20, macos-latest) / Test with Node.js 20 on macos-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/Users/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / test (18, macos-latest) / Test with Node.js 18 on macos-latest

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/Users/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:203:9) at Test.run (node:internal/test_runner/test:631:25) at Test.processPendingSubtests (node:internal/test_runner/test:374:18) at Test.postRun (node:internal/test_runner/test:715:19) at Test.run (node:internal/test_runner/test:673:12) at async Test.processPendingSubtests (node:internal/test_runner/test:374:7), code: 'ERR_TEST_FAILURE' }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 20 compiled --without-intl

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }

Check failure on line 470 in test/fetch/request.js

View workflow job for this annotation

GitHub Actions / Test with Node.js 21 compiled --without-intl

Clone the set-cookie header when Request is passed as the first parameter and no header is passed.

[Error [ERR_TEST_FAILURE]: assert.strictDeepEqual is not a function] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: TypeError [Error]: assert.strictDeepEqual is not a function at TestContext.<anonymous> (/home/runner/work/undici/undici/test/fetch/request.js:470:10) at Test.runInAsyncScope (node:async_hooks:206:9) at Test.run (node:internal/test_runner/test:639:25) at Test.processPendingSubtests (node:internal/test_runner/test:382:18) at Test.postRun (node:internal/test_runner/test:730:19) at Test.run (node:internal/test_runner/test:688:12) at async Test.processPendingSubtests (node:internal/test_runner/test:382:7) }
tsctx marked this conversation as resolved.
Show resolved Hide resolved
request2.headers.append('set-cookie', 'B')
strictEqual(request.headers.getSetCookie().join(', '), request.headers.get('set-cookie'))
strictEqual(request2.headers.getSetCookie().join(', '), request2.headers.get('set-cookie'))
assert.strictDeepEqual([...request.headers], [['set-cookie', 'A']])
tsctx marked this conversation as resolved.
Show resolved Hide resolved
assert.strictEqual(request.headers.getSetCookie().join(', '), request.headers.get('set-cookie'))
assert.strictEqual(request2.headers.getSetCookie().join(', '), request2.headers.get('set-cookie'))
})

// Tests for optimization introduced in https://github.com/nodejs/undici/pull/2456
Expand Down