forked from apollographql/apollo-ios
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow periods in arguments to be ignored when parsing cacheKeys (apol…
…lographql#2057) * Allow commas in arguments to be ignored when parsing cacheKeys * Update * More tests * No-split case
- Loading branch information
1 parent
3e586d0
commit de16a54
Showing
4 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import XCTest | ||
@testable import ApolloSQLite | ||
|
||
final class CacheKeyConstructionTests: XCTestCase { | ||
func testCacheKeySplitsPeriods() { | ||
let input = "my.chemical.romance" | ||
let expected = ["my", "chemical", "romance"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testCacheKeySplitsPeriodsButIgnoresParentheses() { | ||
let input = "my.chemical.romance(xWv.CD-RIP.whole-album)" | ||
let expected = ["my", "chemical", "romance(xWv.CD-RIP.whole-album)"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testCacheKeyIgnoresNestedParentheses() { | ||
let input = "my.chemical.romance(the.(very)hidden.albums)" | ||
let expected = ["my", "chemical", "romance(the.(very)hidden.albums)"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testDoubleNestedInput() { | ||
let input = "my.chemical.romance(name:imnotokay.rip(xWv(the.original).HIGH-QUALITY)).mp3" | ||
let expected = ["my", "chemical", "romance(name:imnotokay.rip(xWv(the.original).HIGH-QUALITY))", "mp3"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testUnbalancedInput() { | ||
let input = "my.chemical.romance(name: )(.thebest.)()" | ||
let expected = ["my", "chemical", "romance(name: )(.thebest.)()"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testUnbalancedInputContinued() { | ||
let input = "my.chemical.romance(name: )(.thebest.)().count" | ||
let expected = ["my", "chemical", "romance(name: )(.thebest.)()", "count"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
|
||
func testNoSplits() { | ||
let input = "mychemicalromance" | ||
let expected = ["mychemicalromance"] | ||
|
||
XCTAssertEqual(input.splitIntoCacheKeyComponents(), expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters