Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

test: Ensure that using extendExcludeFromIndexes and then buildEntityProto always excludes large properties from indexing#1355

Merged
danieljbruce merged 51 commits intoexclude-from-indexes-cleanupfrom
376498253-ensure-exclude-from-indexes-true-is-always-in-the-right-place
Nov 5, 2024
Merged

test: Ensure that using extendExcludeFromIndexes and then buildEntityProto always excludes large properties from indexing#1355
danieljbruce merged 51 commits intoexclude-from-indexes-cleanupfrom
376498253-ensure-exclude-from-indexes-true-is-always-in-the-right-place

Conversation

@danieljbruce
Copy link
Copy Markdown
Contributor

@danieljbruce danieljbruce commented Nov 4, 2024

Summary:

So far, code that searches for large properties has been refactored into an extendExcludeFromIndexes function and code that builds an entity proto with excludeFromIndexes: true in the right places has been pulled into a buildEntityProto function. This PR contains tests which ensure that whenever extendExcludeFromIndexes is used and then buildEntityProto is used that it will always result in an entity proto with excludeFromIndexes: true next to large properties. The new test file ensures this using several handwritten test cases and several generated test cases.

This is a follow-up to this PR.

Changes:

  • test/entity/excludeIndexesAndBuildProto.ts: In this file as described in Summary, a bunch of tests are added that ensure excludeFromIndexes: true is always encoded only next to all the large properties of the entity proto.
  • test/fixtures/complexCaseLargeStrings.ts: This file contains a constant that is now shared in two tests. This constant used to be in the test/gapic-mocks/commit.ts tests.
  • test/gapic-mocks/commit.ts: A constant from this test is extracted into the test/fixtures/complexCaseLargeStrings.ts file so that it can be used elsewhere.

Against the current source code, this test fails because the code throws an error, but it should pass.
Pull out the code that extends the excludeFromIndexes list
The structure change requires another mock.
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: datastore Issues related to the googleapis/nodejs-datastore API. labels Nov 4, 2024
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Nov 5, 2024
@danieljbruce danieljbruce marked this pull request as ready for review November 5, 2024 21:48
@danieljbruce danieljbruce requested a review from a team November 5, 2024 21:48
@danieljbruce danieljbruce requested a review from a team as a code owner November 5, 2024 21:48
@danieljbruce danieljbruce merged commit a8a201f into exclude-from-indexes-cleanup Nov 5, 2024
@danieljbruce danieljbruce deleted the 376498253-ensure-exclude-from-indexes-true-is-always-in-the-right-place branch November 5, 2024 22:11
danieljbruce added a commit that referenced this pull request Nov 6, 2024
#1356)

* fix: The save function should not throw an error for name/value properties in arrays (#1336)

* Add some test cases for findLargeProperties_

* Add a test for arrays and skip it.

* Add a test for the complex case wrapped in an arra

* Add a test case for an array without name/value.

* Add another test for name/value pair

* Change the test case involving a name/value pair

* Add two simple test cases for excludeFromIndexes

* Add another unit test for findLargeProperties_

* Remove if block that stops recursion

* Add a test for save with a `name/value` pair

* Add some test code that ensures name/value encoded

Against the current source code, this test fails because the code throws an error, but it should pass.

* Add header

* Remove only

* Add a test that saves a long string value property

* Add a unit test checking longString for value

* Remove only

* TODO is done

* refactor: Add separate function for adding large properties to the excludeFromIndexes list (#1349)

* Add some test cases for findLargeProperties_

* Add a test for arrays and skip it.

* Add a test for the complex case wrapped in an arra

* Add a test case for an array without name/value.

* Add another test for name/value pair

* Change the test case involving a name/value pair

* Add two simple test cases for excludeFromIndexes

* Add another unit test for findLargeProperties_

* Remove if block that stops recursion

* Add a test for save with a `name/value` pair

* Add some test code that ensures name/value encoded

Against the current source code, this test fails because the code throws an error, but it should pass.

* Add header

* Remove only

* Add a test that saves a long string value property

* Add a unit test checking longString for value

* Remove only

* TODO is done

* Refactor the save function

Pull out the code that extends the excludeFromIndexes list

* Add TODO

* Write unit tests for the new excludeFromIndexes fn

* Add the header

* Document parameter for extendExcludeFromIndexes

* Remove redundant check

* refactor: Add a separate function for building the entity proto (#1350)

* Add some test cases for findLargeProperties_

* Add a test for arrays and skip it.

* Add a test for the complex case wrapped in an arra

* Add a test case for an array without name/value.

* Add another test for name/value pair

* Change the test case involving a name/value pair

* Add two simple test cases for excludeFromIndexes

* Add another unit test for findLargeProperties_

* Remove if block that stops recursion

* Add a test for save with a `name/value` pair

* Add some test code that ensures name/value encoded

Against the current source code, this test fails because the code throws an error, but it should pass.

* Add header

* Remove only

* Add a test that saves a long string value property

* Add a unit test checking longString for value

* Remove only

* TODO is done

* Refactor the save function

Pull out the code that extends the excludeFromIndexes list

* Add TODO

* Write unit tests for the new excludeFromIndexes fn

* Add the header

* Refactor the code for building the entity proto

* Rename it buildEntityProto

* The tests need another mock due to the structure

The structure change requires another mock.

* First two tests for buildEntityProto

* Reintroduce extendExcludeFromIndexes.ts tests

* Adjust the test to match expected proto

* Add another test for an entity in an array

* Add headers

* Add another header

* Eliminate space. Simplify diff

* test: Ensure that using extendExcludeFromIndexes and then buildEntityProto always excludes large properties from indexing (#1355)

* Add some test cases for findLargeProperties_

* Add a test for arrays and skip it.

* Add a test for the complex case wrapped in an arra

* Add a test case for an array without name/value.

* Add another test for name/value pair

* Change the test case involving a name/value pair

* Add two simple test cases for excludeFromIndexes

* Add another unit test for findLargeProperties_

* Remove if block that stops recursion

* Add a test for save with a `name/value` pair

* Add some test code that ensures name/value encoded

Against the current source code, this test fails because the code throws an error, but it should pass.

* Add header

* Remove only

* Add a test that saves a long string value property

* Add a unit test checking longString for value

* Remove only

* TODO is done

* Refactor the save function

Pull out the code that extends the excludeFromIndexes list

* Add TODO

* Write unit tests for the new excludeFromIndexes fn

* Add the header

* Refactor the code for building the entity proto

* Rename it buildEntityProto

* The tests need another mock due to the structure

The structure change requires another mock.

* First two tests for buildEntityProto

* Reintroduce extendExcludeFromIndexes.ts tests

* Adjust the test to match expected proto

* Add another test for an entity in an array

* Add headers

* Add another header

* Add some tests for checkEntityProto

Make sure that checkEntityProto is working correctly.

* Empty commit

* Pull out complexCaseEntities

* Add a few more tests to excludeIndexesAndBuildProto

* Add generated test cases ensuring completeness

* Add a few comments that explain behaviour of block

* Add comments explaining code blocks

* Add a bunch of other generated tests

* Make this test more meaningful for name/value chek

* Fix the generator

* Remove console logs

* Add better test name descriptions

* Add TODO

* Add a comment about the array of arrays test case

* Increase the max depth

* Add headers to the codebase

* Update parameter descriptions

* Add a bunch of parameter documentation

Correct only as well.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: datastore Issues related to the googleapis/nodejs-datastore API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants