Skip to content

Commit

Permalink
Updating Conformance Tests (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 11, 2018
1 parent 78392d3 commit 65d904a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
24 changes: 5 additions & 19 deletions conformance/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const path = require('path');
const is = require('is');
const through = require('through2');
const googleProtoFiles = require('google-proto-files');
const varint = require('varint');
const protobufjs = require('protobufjs');
const grpc = require('grpc');

Expand All @@ -44,30 +43,17 @@ function loadTestCases() {
};

const protoDefinition = protobufRoot.loadSync(
path.join(__dirname, 'test_definition.proto')
path.join(__dirname, 'test-definition.proto')
);

const binaryProtoData = require('fs').readFileSync(
path.join(__dirname, 'test_data.binprotos')
path.join(__dirname, 'test-suite.binproto')
);

const testType = protoDefinition.lookupType('tests.Test');
const testType = protoDefinition.lookupType('tests.TestSuite');
const testSuite = testType.decode(binaryProtoData);

const testCases = [];

for (let offset = 0; offset < binaryProtoData.length; ) {
const messageLength = varint.decode(binaryProtoData, offset);
offset += varint.encodingLength(messageLength);

let testCase = testType.decode(
binaryProtoData.slice(offset, offset + messageLength)
);
testCases.push(testCase);

offset = offset + messageLength;
}

return testCases;
return testSuite.tests;
}

/** Converts a test object into a JS Object suitable for the Node API. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ syntax = "proto3";

package tests;

option csharp_namespace = "Google.Cloud.Firestore.Tests.Proto";
option java_package = "com.google.cloud.firestore.conformance";

import "google/firestore/v1beta1/firestore.proto";
import "google/firestore/v1beta1/common.proto";

// A collection of tests.
message TestSuite {
repeated Test tests = 1;
}

// A Test describes a single client method call and its expected result.
message Test {
string description = 1; // short description of the test
Expand Down Expand Up @@ -96,4 +104,4 @@ message SetOption {
// A field path.
message FieldPath {
repeated string field = 1;
}
}
Binary file not shown.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"prettier": "^1.9.2",
"protobufjs": "^6.8.0",
"proxyquire": "^1.7.11",
"typescript": "^2.5.2",
"varint": "^5.0.0"
"typescript": "^2.5.2"
}
}

0 comments on commit 65d904a

Please sign in to comment.