Visitar URL original
Pulling in the latest version of the Conformance Tests · googleapis/google-cloud-java@bfe6695 · GitHub
Skip to content

Commit bfe6695

Browse files
Pulling in the latest version of the Conformance Tests
1 parent b7b3f21 commit bfe6695

4 files changed

Lines changed: 1835 additions & 1086 deletions

File tree

‎google-cloud-firestore/src/main/java/com/google/cloud/firestore/SetOptions.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,18 @@ public static SetOptions mergeFieldPaths(List<FieldPath> fields) {
121121

122122
/** Returns the EncodingOptions to use for a set() call. */
123123
EncodingOptions getEncodingOptions() {
124-
return merge ? UserDataConverter.ALLOW_ALL_DELETES : UserDataConverter.NO_DELETES;
124+
if (!merge) {
125+
return UserDataConverter.NO_DELETES;
126+
} else if (fieldMask == null) {
127+
return UserDataConverter.ALLOW_ALL_DELETES;
128+
} else {
129+
return new EncodingOptions() {
130+
@Override
131+
public boolean allowDelete(FieldPath fieldPath) {
132+
return fieldMask.contains(fieldPath);
133+
}
134+
};
135+
}
125136
}
126137

127138
@Override

‎google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java‎

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
@RunWith(AllTests.class)
7373
public class ConformanceTest {
74-
private static final String TEST_FILE = "./src/test/resources/test_data.binprotos";
74+
private static final String TEST_FILE = "./src/test/resources/test-suite.binproto";
7575

7676
/** Interface implemented by the conformance test cases. */
7777
private interface ConformanceTestCase extends Test, Describable {}
@@ -138,21 +138,6 @@ private List<FieldPath> convertFields(List<TestDefinition.FieldPath> fieldsList)
138138
return convertedFields;
139139
}
140140

141-
/** Decodes a Protobuf varint. */
142-
public int parseLength(InputStream in) throws IOException {
143-
int res = 0;
144-
int pos = 0;
145-
int b;
146-
while (((b = in.read()) & 0x80) != 0) {
147-
if (b == -1) {
148-
return -1;
149-
}
150-
res |= (b & 0x7F) << pos;
151-
pos += 7;
152-
}
153-
return res | (b << pos);
154-
}
155-
156141
/** Converts a JSON string into a Java Map. */
157142
private Map<String, Object> convertInput(String jsonData) {
158143
Type type = new TypeToken<Map<String, Object>>() {}.getType();
@@ -214,19 +199,10 @@ private List<Object> convertArray(List<Object> list) {
214199
/** Reads the test definition from the Proto file. */
215200
private List<Test> parseTests() throws IOException {
216201
List<Test> tests = new ArrayList<>();
217-
FileInputStream inputStream = new FileInputStream(TEST_FILE);
218-
219-
int length;
220-
while ((length = parseLength(inputStream)) != -1) {
221-
byte[] buffer = new byte[length];
222-
int read = inputStream.read(buffer);
223-
Preconditions.checkState(
224-
length == read,
225-
"Encountered unexpected length for test case. Expected %d, but was %d",
226-
length,
227-
read);
228-
TestDefinition.Test testDefinition = TestDefinition.Test.parseFrom(buffer);
229202

203+
TestDefinition.TestSuite testSuite = TestDefinition.TestSuite.parseFrom(
204+
new FileInputStream(TEST_FILE));
205+
for (TestDefinition.Test testDefinition : testSuite.getTestsList()) {
230206
if (!includedTests.isEmpty() && !includedTests.contains(testDefinition.getDescription())
231207
|| excludedTests.contains(testDefinition.getDescription())) {
232208
continue;

0 commit comments

Comments
 (0)