Skip to content

Commit f95a6f2

Browse files
test: fix samples test that was broken by a test harness change (#2284)
The test was broken in #2170 which added a new column family. The test was relient on the abolute column family count of the schema. This PR fixes the test by making it focus on the family its trying to delete instead of the entire schema Change-Id: I0df90e68c0b25c4e66ed7d8ae1c19ae53577443b Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Rollback plan is reviewed and LGTMed - [ ] All new data plane features have a completed end to end testing plan Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 9062944 commit f95a6f2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.42.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.43.0')
5454
5555
implementation 'com.google.cloud:google-cloud-bigtable'
5656
```
5757
If you are using Gradle without BOM, add this to your dependencies:
5858

5959
```Groovy
60-
implementation 'com.google.cloud:google-cloud-bigtable:2.39.5'
60+
implementation 'com.google.cloud:google-cloud-bigtable:2.40.0'
6161
```
6262

6363
If you are using SBT, add this to your dependencies:
6464

6565
```Scala
66-
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "2.39.5"
66+
libraryDependencies += "com.google.cloud" % "google-cloud-bigtable" % "2.40.0"
6767
```
6868
<!-- {x-version-update-end} -->
6969

@@ -542,7 +542,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
542542
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigtable/java11.html
543543
[stability-image]: https://img.shields.io/badge/stability-stable-green
544544
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigtable.svg
545-
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigtable/2.39.5
545+
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigtable/2.40.0
546546
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
547547
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
548548
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

samples/snippets/src/test/java/com/example/bigtable/deletes/DeletesTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
import com.example.bigtable.MobileTimeSeriesBaseTest;
2020
import com.google.api.gax.rpc.ServerStream;
2121
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
22+
import com.google.cloud.bigtable.admin.v2.models.ColumnFamily;
2223
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
2324
import com.google.cloud.bigtable.data.v2.models.Query;
2425
import com.google.cloud.bigtable.data.v2.models.Row;
2526
import com.google.cloud.bigtable.data.v2.models.RowCell;
2627
import com.google.cloud.bigtable.data.v2.models.TableId;
28+
import com.google.common.truth.Correspondence;
2729
import com.google.common.truth.Truth;
2830
import java.io.IOException;
2931
import java.util.List;
@@ -39,6 +41,8 @@
3941
*/
4042
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4143
public class DeletesTest extends MobileTimeSeriesBaseTest {
44+
private static final Correspondence<ColumnFamily, String> COLUMN_FAMILY_ID_CORRESPONDENCE =
45+
Correspondence.transforming(ColumnFamily::getId, "ColumnFamily id");
4246
public static BigtableDataClient bigtableDataClient;
4347

4448
@BeforeClass
@@ -164,13 +168,17 @@ public void test6_testDeleteFromColumnFamily() throws IOException {
164168
public void test7_testDeleteColumnFamily() throws IOException {
165169
try (BigtableTableAdminClient tableAdminClient =
166170
BigtableTableAdminClient.create(projectId, instanceId)) {
167-
Truth.assertThat(tableAdminClient.getTable(TABLE_ID).getColumnFamilies().size()).isEqualTo(2);
171+
Truth.assertThat(tableAdminClient.getTable(TABLE_ID).getColumnFamilies())
172+
.comparingElementsUsing(COLUMN_FAMILY_ID_CORRESPONDENCE)
173+
.contains(COLUMN_FAMILY_NAME_STATS);
168174

169175
DeleteColumnFamilyExample deleteColumnFamilyExample = new DeleteColumnFamilyExample();
170176
deleteColumnFamilyExample.deleteColumnFamily(
171177
projectId, instanceId, TABLE_ID, COLUMN_FAMILY_NAME_STATS);
172178

173-
Truth.assertThat(tableAdminClient.getTable(TABLE_ID).getColumnFamilies().size()).isEqualTo(1);
179+
Truth.assertThat(tableAdminClient.getTable(TABLE_ID).getColumnFamilies())
180+
.comparingElementsUsing(COLUMN_FAMILY_ID_CORRESPONDENCE)
181+
.doesNotContain(COLUMN_FAMILY_NAME_STATS);
174182
}
175183
}
176184

0 commit comments

Comments
 (0)