Skip to content

[test] Rewrite URLSession cookie tests to be independent. #2527

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

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

drodriguez
Copy link
Contributor

Some cookie tests were depending on previously run tests to be
successful. Rewrite all the tests to be independent from each other.

The first change is that all the tests that deal with cookies try to
clean their cookie storages before starting the testing. This should
avoid previous state leaking into the current test.

Some other changes are made to clarify how the cookie tests are actually
performed. To check that the cookies are set by URLSession, an special
endpoint that echoes back the request header are used. To make it clear,
that endpoint has changed names.

In the cases that we were checking that the response headers were
setting the cookies, we actually check for the right headers to been
set, not some random data in the response (because for some reason, the
request headers were also being echo in another endpoint, which might
have created false positives).

There is also some cleaning of unused variables and var that should have
been let.

I tested this by running all the tests in TestURLSession in the same
run, and also running the individual tests one by one from the command
line.

I recommend reading this diff with whitespace changes disabled (?w=1 in the address bar).

Some cookie tests were depending on previously run tests to be
successful. Rewrite all the tests to be independent from each other.

The first change is that all the tests that deal with cookies try to
clean their cookie storages before starting the testing. This should
avoid previous state leaking into the current test.

Some other changes are made to clarify how the cookie tests are actually
performed. To check that the cookies are set by URLSession, an special
endpoint that echoes back the request header are used. To make it clear,
that endpoint has changed names.

In the cases that we were checking that the response headers were
setting the cookies, we actually check for the right headers to been
set, not some random data in the response (because for some reason, the
request headers were also being echo in another endpoint, which might
have created false positives).

There is also some cleaning of unused variables and var that should have
been let.

I tested this by running all the tests in TestURLSession in the same
run, and also running the individual tests one by one from the command
line.
@drodriguez drodriguez requested a review from spevans September 30, 2019 22:12
@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez
Copy link
Contributor Author

Found in the review of #2521.

@millenomi millenomi merged commit 7165d15 into swiftlang:master Oct 4, 2019
@drodriguez drodriguez deleted the tests-rewrite-cookie-tests branch October 4, 2019 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants