Skip to content

Commit

Permalink
fix: make generated test more TypeScript-y (#93)
Browse files Browse the repository at this point in the history
* fix: make test more typescripty

* update circle

* more circle
  • Loading branch information
alexander-fenster authored Oct 31, 2019
1 parent 712516f commit 128f4af
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 20 deletions.
17 changes: 14 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,36 @@ jobs:
npm install
npm test
- run:
name: Run unit tests of the generated Showcase library
name: Run unit tests and gts fix of the generated Showcase library
command: |
cd .test-out-showcase
npm install
npm test
npm run fix
- run:
name: Run unit tests of the generated KMS library
name: Run unit tests and gts fix of the generated KMS library
command: |
cp -r typescript/test/protos ./.test-out-keymanager
cd .test-out-keymanager
npm install
npm test
npm run fix
- run:
name: Run unit tests of the generated Text-to-Speech library
name: Run unit tests and gts fix of the generated Translate library
command: |
cp -r typescript/test/protos ./.test-out-translate
cd .test-out-translate
npm install
npm test
npm run fix
- run:
name: Run unit tests and gts fix of the generated Text-to-Speech library
command: |
cp -r typescript/test/protos ./.test-out-texttospeech
cd .test-out-texttospeech
npm install
npm test
npm run fix
- run:
name: Run linting
command: |
Expand Down
1 change: 1 addition & 0 deletions templates/typescript_gapic/package.json.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"google-gax": "^1.7.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/mocha": "^5.2.5",
"gts": "^0.9.0",
"mocha": "^6.0.0",
Expand Down
11 changes: 7 additions & 4 deletions templates/typescript_gapic/test/gapic-$service-$version.ts.njk
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{% import "../_license.njk" as license -%}
{% import "../_util.njk" as util -%}
{{license.license()}}
'use strict';
import * as protosTypes from '../protos/protos';
const assert = require('assert');
import * as assert from 'assert';
const {{ service.name.toLowerCase() }}Module = require('../src');
{% if (service.streaming.length > 0) %}
const {PassThrough} = require('stream');
import {PassThrough} from 'stream';
{% endif %}

const FAKE_STATUS_CODE = 1;
class FakeError{
name: string;
message: string;
code: number;
constructor(n: number){
this.name = 'fakeName';
this.message = 'fake message';
this.code = n;
}
}
const error = new FakeError(FAKE_STATUS_CODE);
export interface Callback {
(err: FakeError|null, response?: {} | null): {};
(err: FakeError|null, response?: {} | null): void;
}

export class Operation{
Expand Down
1 change: 1 addition & 0 deletions typescript/test/testdata/keymanager/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"google-gax": "^1.7.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/mocha": "^5.2.5",
"gts": "^0.9.0",
"mocha": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';
import * as protosTypes from '../protos/protos';
const assert = require('assert');
import * as assert from 'assert';
const keymanagementserviceModule = require('../src');


const FAKE_STATUS_CODE = 1;
class FakeError{
name: string;
message: string;
code: number;
constructor(n: number){
this.name = 'fakeName';
this.message = 'fake message';
this.code = n;
}
}
const error = new FakeError(FAKE_STATUS_CODE);
export interface Callback {
(err: FakeError|null, response?: {} | null): {};
(err: FakeError|null, response?: {} | null): void;
}

export class Operation{
Expand Down
1 change: 1 addition & 0 deletions typescript/test/testdata/showcase/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"google-gax": "^1.7.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/mocha": "^5.2.5",
"gts": "^0.9.0",
"mocha": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';
import * as protosTypes from '../protos/protos';
const assert = require('assert');
import * as assert from 'assert';
const echoModule = require('../src');

const {PassThrough} = require('stream');
import {PassThrough} from 'stream';


const FAKE_STATUS_CODE = 1;
class FakeError{
name: string;
message: string;
code: number;
constructor(n: number){
this.name = 'fakeName';
this.message = 'fake message';
this.code = n;
}
}
const error = new FakeError(FAKE_STATUS_CODE);
export interface Callback {
(err: FakeError|null, response?: {} | null): {};
(err: FakeError|null, response?: {} | null): void;
}

export class Operation{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"google-gax": "^1.7.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/mocha": "^5.2.5",
"gts": "^0.9.0",
"mocha": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';
import * as protosTypes from '../protos/protos';
const assert = require('assert');
import * as assert from 'assert';
const texttospeechModule = require('../src');


const FAKE_STATUS_CODE = 1;
class FakeError{
name: string;
message: string;
code: number;
constructor(n: number){
this.name = 'fakeName';
this.message = 'fake message';
this.code = n;
}
}
const error = new FakeError(FAKE_STATUS_CODE);
export interface Callback {
(err: FakeError|null, response?: {} | null): {};
(err: FakeError|null, response?: {} | null): void;
}

export class Operation{
Expand Down
1 change: 1 addition & 0 deletions typescript/test/testdata/translate/package.json.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"google-gax": "^1.7.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/mocha": "^5.2.5",
"gts": "^0.9.0",
"mocha": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';
import * as protosTypes from '../protos/protos';
const assert = require('assert');
import * as assert from 'assert';
const translationserviceModule = require('../src');


const FAKE_STATUS_CODE = 1;
class FakeError{
name: string;
message: string;
code: number;
constructor(n: number){
this.name = 'fakeName';
this.message = 'fake message';
this.code = n;
}
}
const error = new FakeError(FAKE_STATUS_CODE);
export interface Callback {
(err: FakeError|null, response?: {} | null): {};
(err: FakeError|null, response?: {} | null): void;
}

export class Operation{
Expand Down

0 comments on commit 128f4af

Please sign in to comment.