Fix generation of episodic nodejs for services
- Extending services from the episode must also take the episodes into account
- Remove the reference in the generated ts for imported types since it can't be relative
- Extend the tests
diff --git a/lib/nodejs/test/episodic-code-generation-test/client.js b/lib/nodejs/test/episodic-code-generation-test/client.js
index cf014c2..57f520f 100644
--- a/lib/nodejs/test/episodic-code-generation-test/client.js
+++ b/lib/nodejs/test/episodic-code-generation-test/client.js
@@ -23,19 +23,32 @@
const test = require("tape");
const thrift = require("thrift");
const { program } = require("commander");
+const tape = require("tape");
program
.option("--host <host>", "Set the thrift server host to connect", "localhost")
.option("--port <port>", "Set the thrift server port number to connect", 9090)
+ .option("--base <base>", "Set the base: 'pure', 'base' or 'extend'", "pure")
.parse(process.argv);
-const Service = require("./gen-2/second-episode/gen-nodejs/Service");
+const ServiceBase = require("types-package/first-episode/BaseService");
+const ServicePure = require("./gen-2/second-episode/gen-nodejs/Service");
+const ServiceExtended = require("./gen-2/second-episode/gen-nodejs/ExtendedService");
const Types = require("types-package/first-episode/Types_types");
const opts = program.opts();
const host = opts.host;
const port = opts.port;
+let Service;
+if (opts.base === "pure") {
+ Service = ServicePure;
+} else if (opts.base === "base") {
+ Service = ServiceBase;
+} else if (opts.base === "extend") {
+ Service = ServiceExtended;
+}
+
const options = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
@@ -58,6 +71,24 @@
callback("Server successfully tested");
});
});
+
+ if (opts.base === "extend") {
+ test("NodeJS episodic compilation client-server extended test", function (assert) {
+ const type1Object = new Types.Type1();
+ type1Object.number = 42;
+ type1Object.message = "The answer";
+ client.testEpisodeExtend(type1Object, function (err, response) {
+ assert.error(err, "no callback error");
+ assert.equal(response.number, type1Object.number + 1);
+ assert.equal(
+ response.message,
+ type1Object.message + " [Hello from the extended server]",
+ );
+ assert.end();
+ callback("Extended Server successfully tested");
+ });
+ });
+ }
};
connection.on("error", function (err) {
@@ -71,6 +102,9 @@
function runTests() {
testDriver(client, function (status) {
console.log(status);
+ });
+ tape.onFinish(function () {
+ console.log("Tests finished");
connection.destroy();
});
}