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

Add initializer that takes database Connection #1330

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

mdarnall
Copy link
Contributor

@mdarnall mdarnall commented Jul 27, 2020

Updated SQLiteNormalizedCache

Because:

This commit:

  • Adds a new initializer to SQLiteNormalizedCache

@apollo-cla
Copy link

@mdarnall: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

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

One comment I can fix post-merge if you'd prefer - otherwise looks good!

@@ -59,6 +60,12 @@ class CachePersistenceTests: XCTestCase {
}
}

func testPassInConnection() {
let connection = try? Connection()
XCTAssertNotNil(connection)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend making the test a throws test so you don't have to mess around with unwrapping:

func testPassInConnection() throws {
  let connection = try Connection()
  let cache = try SQLiteNormalizedCache(db: connection)
  // Something that tests that the cache exists
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sure I can update that.. thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@designatednerd I updated this to hopefully simplify, but didn't know if there was really a good way to "tests that the cache exists". Instead, I'm simply asserting the creation does not throw.

Copy link
Contributor

Choose a reason for hiding this comment

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

That works too!

Because:
- It will allow consumers to further configure the Connection in their
application and pass it in
- See: https://github.com/apollographql/apollo-ios/pull/1162/files#r410367735
This commit:
- Adds a new initializer to SQLNormalizedCache
Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

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

👍 pending CI

@designatednerd designatednerd merged commit 791b70a into apollographql:main Jul 27, 2020
@designatednerd designatednerd added this to the Next Release milestone Jul 27, 2020
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.

3 participants