@@ -29,13 +29,18 @@ class TestHTTPCookieStorage: XCTestCase {
29
29
( " test_BasicStorageAndRetrieval " , test_BasicStorageAndRetrieval) ,
30
30
( " test_deleteCookie " , test_deleteCookie) ,
31
31
( " test_removeCookies " , test_removeCookies) ,
32
- ( " test_setCookiesForURL " , test_setCookiesForURL) ,
33
- ( " test_getCookiesForURL " , test_getCookiesForURL) ,
34
- ( " test_setCookiesForURLWithMainDocumentURL " , test_setCookiesForURLWithMainDocumentURL) ,
32
+ ( " test_cookiesForURL " , test_cookiesForURL) ,
33
+ ( " test_cookiesForURLWithMainDocumentURL " , test_cookiesForURLWithMainDocumentURL) ,
35
34
( " test_cookieInXDGSpecPath " , test_cookieInXDGSpecPath) ,
36
35
]
37
36
}
38
37
38
+ override func setUp( ) {
39
+ // Delete any cookies in the storage
40
+ getStorage ( for: . shared) . removeCookies ( since: Date ( timeIntervalSince1970: 0 ) )
41
+ getStorage ( for: . groupContainer( " test " ) ) . removeCookies ( since: Date ( timeIntervalSince1970: 0 ) )
42
+ }
43
+
39
44
func test_sharedCookieStorageAccessedFromMultipleThreads( ) {
40
45
let q = DispatchQueue . global ( )
41
46
let syncQ = DispatchQueue ( label: " TestHTTPCookieStorage.syncQ " )
@@ -72,17 +77,15 @@ class TestHTTPCookieStorage: XCTestCase {
72
77
removeCookies ( with: . groupContainer( " test " ) )
73
78
}
74
79
75
- func test_setCookiesForURL ( ) {
80
+ func test_cookiesForURL ( ) {
76
81
setCookiesForURL ( with: . shared)
77
- setCookiesForURL ( with: . groupContainer( " test " ) )
78
- }
79
-
80
- func test_getCookiesForURL( ) {
81
82
getCookiesForURL ( with: . shared)
83
+
84
+ setCookiesForURL ( with: . groupContainer( " test " ) )
82
85
getCookiesForURL ( with: . groupContainer( " test " ) )
83
86
}
84
87
85
- func test_setCookiesForURLWithMainDocumentURL ( ) {
88
+ func test_cookiesForURLWithMainDocumentURL ( ) {
86
89
setCookiesForURLWithMainDocumentURL ( with: . shared)
87
90
setCookiesForURLWithMainDocumentURL ( with: . groupContainer( " test " ) )
88
91
}
@@ -159,9 +162,11 @@ class TestHTTPCookieStorage: XCTestCase {
159
162
. expires: Date ( timeIntervalSince1970: Date ( ) . timeIntervalSince1970 + 1000 )
160
163
] ) !
161
164
storage. setCookie ( simpleCookie)
165
+ storage. setCookie ( simpleCookie2)
162
166
XCTAssertEqual ( storage. cookies!. count, 2 )
163
167
164
168
storage. deleteCookie ( simpleCookie)
169
+ XCTAssertEqual ( storage. cookies!. count, 1 )
165
170
storage. deleteCookie ( simpleCookie2)
166
171
XCTAssertEqual ( storage. cookies!. count, 0 )
167
172
}
@@ -225,7 +230,7 @@ class TestHTTPCookieStorage: XCTestCase {
225
230
. domain: " swift.org " ,
226
231
] ) !
227
232
storage. setCookies ( [ simpleCookie] , for: url, mainDocumentURL: mainUrl)
228
- XCTAssertEqual ( storage. cookies ( for: url!) !. count, 2 )
233
+ XCTAssertEqual ( storage. cookies ( for: url!) !. count, 1 )
229
234
230
235
let url1 = URL ( string: " https://dt.swift.org/downloads " )
231
236
let simpleCookie1 = HTTPCookie ( properties: [
@@ -249,7 +254,7 @@ class TestHTTPCookieStorage: XCTestCase {
249
254
] ) !
250
255
let storage = HTTPCookieStorage . shared
251
256
storage. setCookie ( testCookie)
252
- XCTAssertEqual ( storage. cookies!. count, 3 )
257
+ XCTAssertEqual ( storage. cookies!. count, 1 )
253
258
var destPath : String
254
259
let bundlePath = Bundle . main. bundlePath
255
260
var bundleName = " / " + bundlePath. components ( separatedBy: " / " ) . last!
0 commit comments