Skip to content

Commit 3a3c5fc

Browse files
kolea2gcf-owl-bot[bot]
authored andcommitted
test: add integration test for incomplete key (#1460)
* test: add integration test for incomplete key * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent a659872 commit 3a3c5fc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public class ITDatastoreTest {
144144
private static Key KEY3;
145145
private static Key KEY4;
146146
private static Key KEY5;
147+
private static Key KEY6;
147148
private static final String MARKS_KIND = "Marks";
148149
private static FullEntity<IncompleteKey> PARTIAL_ENTITY1;
149150
private static FullEntity<IncompleteKey> PARTIAL_ENTITY2;
@@ -193,6 +194,10 @@ public ITDatastoreTest(
193194
KEY3 = Key.newBuilder(KEY2).setName("bla").setNamespace(NAMESPACE).build();
194195
KEY4 = Key.newBuilder(KEY2).setName("newName1").setNamespace(NAMESPACE).build();
195196
KEY5 = Key.newBuilder(KEY2).setName("newName2").setNamespace(NAMESPACE).build();
197+
KEY6 =
198+
Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId())
199+
.setNamespace(NAMESPACE)
200+
.build();
196201

197202
LIST_VALUE2 = ListValue.of(Collections.singletonList(KeyValue.of(KEY1)));
198203

@@ -1787,6 +1792,21 @@ public void testGet() {
17871792
assertFalse(entity.contains("bla"));
17881793
}
17891794

1795+
@Test
1796+
public void testIncompleteKey() {
1797+
Key parentKey = null;
1798+
try {
1799+
IncompleteKey incompleteKey = IncompleteKey.newBuilder(KEY6, KIND1).build();
1800+
parentKey = incompleteKey.getParent();
1801+
Entity entity = Entity.newBuilder(parentKey).set("name", "val").build();
1802+
datastore.put(entity);
1803+
Entity retrievedEntity = datastore.get(parentKey);
1804+
assertThat(retrievedEntity).isEqualTo(entity);
1805+
} finally {
1806+
datastore.delete(parentKey);
1807+
}
1808+
}
1809+
17901810
@Test
17911811
public void testGetWithReadTime() throws InterruptedException {
17921812
Key key =

0 commit comments

Comments
 (0)