Skip to content

Fix integration test#1078

Closed
tonidero wants to merge 2 commits into
mainfrom
fix-integration-test
Closed

Fix integration test#1078
tonidero wants to merge 2 commits into
mainfrom
fix-integration-test

Conversation

@tonidero

@tonidero tonidero commented Jun 21, 2023

Copy link
Copy Markdown
Contributor

Description

This integration test broke in #1073. The error was that the schemaVersion field in the customer info didn't match between the fetched and cached customer info. It was actually luck that made it work before 😬 .

Before that change, this test tried to get customer info twice: On sdk configuration and the first part of the test. Since both of these happen pretty quickly, we only made the request once and called both callbacks with the same response. However, the first request actually modified the JSONObject, adding the schema version and some other fields in order to cache it in the device. This made it so the JSONObject actually had those fields in the second callback, causing the schemaVersion to have a value. Then, the value returned from cache already has the schemaVersion field set so the test passed.

After the change in #1073, the test still tries to get customer info twice, but the raw json sharing didn't happen, since when we call getCustomerInfo we now need to check first for unsynced purchases, causing us to not share the callback, so the schema version that was set in the first callback wasn't shared with the second one, causing the schemaVersion field to be 0, causing the test to fail

It took me a while to debug this 😞

@tonidero tonidero added the test label Jun 21, 2023
@tonidero tonidero marked this pull request as ready for review June 21, 2023 08:38
@codecov

codecov Bot commented Jun 21, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1078 (3a62d0e) into main (f030cbb) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1078   +/-   ##
=======================================
  Coverage   85.86%   85.86%           
=======================================
  Files         179      179           
  Lines        6362     6362           
  Branches      876      876           
=======================================
  Hits         5463     5463           
  Misses        557      557           
  Partials      342      342           

@tonidero tonidero requested a review from a team June 21, 2023 12:02

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice job debugging this.

Isn’t this test change covering for an implementation detail though?

I wonder if it would be best to make equals ignore the version.

@tonidero

Copy link
Copy Markdown
Contributor Author

Maybe... I don't think we care much about the schemaVersion in the equals as you said, but I didn't want to modify the behavior. That said, after talking in Slack, I believe I'm going to close this and just default the CustomerInfo schemaVersion to the latest version known by the device, that should also fix the issue.

@tonidero

Copy link
Copy Markdown
Contributor Author

I'm going to close this in favor of #1080

@tonidero tonidero closed this Jun 22, 2023
@tonidero tonidero deleted the fix-integration-test branch June 22, 2023 08:52
tonidero added a commit that referenced this pull request Jun 22, 2023
### Description
An integration test started failing due to #1073. The error was that the
schemaVersion field in the customer info didn't match between the
fetched and cached customer info. It was actually luck that made it work
before 😬 .

Before that change, this test tried to get customer info twice: On sdk
configuration and the first part of the test. Since both of these happen
pretty quickly, we only made the request once and called both callbacks
with the same response. However, the first request actually modified the
JSONObject, adding the schema version and some other fields in order to
cache it in the device. This made it so the JSONObject actually had
those fields in the second callback, causing the schemaVersion to have a
value. Then, the value returned from cache already has the schemaVersion
field set so the test passed.

After the change in
#1073, the test
still tries to get customer info twice, but the raw json sharing didn't
happen, since when we call getCustomerInfo we now need to check first
for unsynced purchases, causing us to not share the callback, so the
schema version that was set in the first callback wasn't shared with the
second one, causing the schemaVersion field to be 0, causing the test to
fail.

After talking about it, we think defaulting the schema version to the
latest known version by the SDK is probably expected behavior, instead
of defaulting to 0 before it's been saved.

Followup to #1078
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