Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert system tests to typescript #424

Merged
merged 2 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,18 @@
"codecov": "nyc report --reporter=json && codecov -f .coverage/*.json",
"docs": "jsdoc -c .jsdoc.js",
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
"system-test": "mocha system-test/ --timeout 600000",
"system-test": "mocha build/system-test --timeout 600000",
"presystem-test": "npm run compile",
"test-only": "nyc mocha build/test",
"test": "npm run test-only",
"pretest-only": "npm run compile",
"lint": "eslint samples/ system-test/ && gts check",
"lint": "eslint samples/ && gts check",
"samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../",
"all-test": "npm test && npm run system-test && npm run samples-test",
"check": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix && eslint --fix samples/**/*.js system-test/",
"fix": "gts fix && eslint --fix samples/**/*.js",
"prepare": "npm run compile"
},
"nyc": {
Expand Down
3 changes: 1 addition & 2 deletions src/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,12 @@ class AclRoleAccessorMethods {
* @param {object} options Configuration options.
*/
class Acl extends AclRoleAccessorMethods {
default?: Acl;
default !: Acl;
pathPrefix;
request_;

constructor(options) {
super();

this.pathPrefix = options.pathPrefix;
this.request_ = options.request;
}
Expand Down
19 changes: 10 additions & 9 deletions src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ interface BucketOptions {
* @param {File[]} files Array of {@link File} instances.
*/
export interface GetFilesCallback {
(err: Error|null, files?: File[]): void;
(err: Error|null, files?: File[], nextQuery?: {},
apiResponse?: request.Response): void;
}

/**
Expand All @@ -69,13 +70,13 @@ export interface GetFilesCallback {
* body](https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll).
*/
interface WatchAllOptions {
delimiter: string;
maxResults: number;
pageToken: string;
prefix: string;
projection: string;
userProject: string;
versions: boolean;
delimiter?: string;
maxResults?: number;
pageToken?: string;
prefix?: string;
projection?: string;
userProject?: string;
versions?: boolean;
}

/**
Expand Down Expand Up @@ -2349,7 +2350,7 @@ class Bucket extends ServiceObject {
* //-
* bucket.setStorageClass('regional').then(function() {});
*/
setStorageClass(storageClass, options, callback) {
setStorageClass(storageClass, options, callback?) {
// In case we get input like `storageClass`, convert to `storage_class`.
storageClass = storageClass.replace(/-/g, '_')
.replace(
Expand Down
4 changes: 2 additions & 2 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const GS_URL_REGEXP = /^gs:\/\/([a-z0-9_.-]+)\/(.+)$/;
* billed for all requests made from File object.
*/
export interface FileOptions {
encryptionKey?: string;
encryptionKey?: string|Buffer;
generation?: number|string;
kmsKeyName?: string;
userProject?: string;
Expand Down Expand Up @@ -2475,7 +2475,7 @@ class File extends ServiceObject {
* //-
* file.setStorageClass('regional').then(function() {});
*/
setStorageClass(storageClass, options, callback) {
setStorageClass(storageClass, options, callback?) {
if (is.fn(options)) {
callback = options;
options = {};
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'use strict';

import * as arrify from 'arrify';
import {Service, GoogleAuthOptions} from '@google-cloud/common';
import {Service, GoogleAuthOptions, CreateOptions} from '@google-cloud/common';
import {paginator} from '@google-cloud/paginator';
import {promisifyAll} from '@google-cloud/promisify';
import * as extend from 'extend';
Expand All @@ -38,7 +38,8 @@ export interface StorageOptions extends GoogleAuthOptions {
promise?: typeof Promise;
}

export interface BucketOptions {
export interface BucketOptions extends CreateOptions {
location?: string;
kmsKeyName?: string;
userProject?: string;
}
Expand Down Expand Up @@ -558,7 +559,7 @@ class Storage extends Service {
* region_tag:storage_list_buckets
* Another example:
*/
getBuckets(query, callback) {
getBuckets(query, callback?) {
if (!callback) {
callback = query;
query = {};
Expand Down Expand Up @@ -640,7 +641,7 @@ class Storage extends Service {
* const apiResponse = data[1];
* });
*/
getServiceAccount(options, callback) {
getServiceAccount(options, callback?) {
if (!callback) {
callback = options;
options = {};
Expand Down Expand Up @@ -719,3 +720,5 @@ promisifyAll(Storage, {
* Full quickstart example:
*/
export {Storage};

export {Bucket, File, Channel};
Loading