Skip to content

Add a testcase for HTTPCookieStorage.description #1359

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
Dec 27, 2017

Conversation

vipinmenon
Copy link
Contributor

Per the guidance in #1313 this PR splits out the test for HTTPCookieStorage.description

cc @ianpartridge

Copy link
Contributor

@alblue alblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor comment - please fix and rebase. Can you also amend the commit message to start with a capital letter and include a verb? For example:

"Add a test case for HTTPCookieStorage.description"

@@ -32,6 +32,7 @@ class TestHTTPCookieStorage: XCTestCase {
("test_cookiesForURL", test_cookiesForURL),
("test_cookiesForURLWithMainDocumentURL", test_cookiesForURLWithMainDocumentURL),
("test_cookieInXDGSpecPath", test_cookieInXDGSpecPath),
("test_descriptionCookie", test_descriptionCookie)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comma at the end, so it doesn't cause unnecessary noise later

@ianpartridge ianpartridge self-requested a review December 7, 2017 11:25
@ianpartridge
Copy link
Contributor

Please remove the XCTAssertEqual(storage.description, ...) lines from other tests now that we are testing the description in its own test.

@@ -246,6 +252,23 @@ class TestHTTPCookieStorage: XCTestCase {
XCTAssertEqual(storage.cookies(for: url1!)!.count, 0)
}

func descriptionCookie(with storageType: _StorageType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this function is only used inside test_descriptionCookie() why not make it a nested function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianpartridge I see that this pattern (calling a function XXX two times from test_XXX) is used in all the tests in TestHTTPCookieStorage. Do you think doing this as a separate PR will make more sense?

@@ -246,6 +252,23 @@ class TestHTTPCookieStorage: XCTestCase {
XCTAssertEqual(storage.cookies(for: url1!)!.count, 0)
}

func descriptionCookie(with storageType: _StorageType) {
let storage = getStorage(for: storageType)
XCTAssertEqual(storage.description, "<NSHTTPCookieStorage cookies count:\(storage.cookies!.count)>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is done elsewhere in the tests but I don't like force unwrapping. If it fails, the whole testsuite blows up. It's better to do:

guard let cookies = storage.cookies else {
    XCTFail("No cookies")
    return
}
etc...

@vipinmenon
Copy link
Contributor Author

@ianpartridge @alblue Thanks for the review. I have responded to the comments. Kindly approve.

@pushkarnk
Copy link
Member

@swift-ci please test

@pushkarnk pushkarnk changed the title testcase for HTTPCookieStorage.description Add a testcase for HTTPCookieStorage.description Dec 15, 2017
@pushkarnk
Copy link
Member

I see that all of the comments have been addressed.

@swift-ci please test and merge

@swift-ci swift-ci merged commit 972bd9d into swiftlang:master Dec 27, 2017
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.

5 participants