Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit b207a36

Browse files
chore: convert system tests to typescript (#424)
1 parent b400ae6 commit b207a36

8 files changed

Lines changed: 2601 additions & 2794 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@
5757
"codecov": "nyc report --reporter=json && codecov -f .coverage/*.json",
5858
"docs": "jsdoc -c .jsdoc.js",
5959
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
60-
"system-test": "mocha system-test/ --timeout 600000",
60+
"system-test": "mocha build/system-test --timeout 600000",
61+
"presystem-test": "npm run compile",
6162
"test-only": "nyc mocha build/test",
6263
"test": "npm run test-only",
6364
"pretest-only": "npm run compile",
64-
"lint": "eslint samples/ system-test/ && gts check",
65+
"lint": "eslint samples/ && gts check",
6566
"samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../",
6667
"all-test": "npm test && npm run system-test && npm run samples-test",
6768
"check": "gts check",
6869
"clean": "gts clean",
6970
"compile": "tsc -p .",
70-
"fix": "gts fix && eslint --fix samples/**/*.js system-test/",
71+
"fix": "gts fix && eslint --fix samples/**/*.js",
7172
"prepare": "npm run compile"
7273
},
7374
"nyc": {

src/acl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,12 @@ class AclRoleAccessorMethods {
320320
* @param {object} options Configuration options.
321321
*/
322322
class Acl extends AclRoleAccessorMethods {
323-
default?: Acl;
323+
default !: Acl;
324324
pathPrefix;
325325
request_;
326326

327327
constructor(options) {
328328
super();
329-
330329
this.pathPrefix = options.pathPrefix;
331330
this.request_ = options.request;
332331
}

src/bucket.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ interface BucketOptions {
6060
* @param {File[]} files Array of {@link File} instances.
6161
*/
6262
export interface GetFilesCallback {
63-
(err: Error|null, files?: File[]): void;
63+
(err: Error|null, files?: File[], nextQuery?: {},
64+
apiResponse?: request.Response): void;
6465
}
6566

6667
/**
@@ -69,13 +70,13 @@ export interface GetFilesCallback {
6970
* body](https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll).
7071
*/
7172
interface WatchAllOptions {
72-
delimiter: string;
73-
maxResults: number;
74-
pageToken: string;
75-
prefix: string;
76-
projection: string;
77-
userProject: string;
78-
versions: boolean;
73+
delimiter?: string;
74+
maxResults?: number;
75+
pageToken?: string;
76+
prefix?: string;
77+
projection?: string;
78+
userProject?: string;
79+
versions?: boolean;
7980
}
8081

8182
/**
@@ -2349,7 +2350,7 @@ class Bucket extends ServiceObject {
23492350
* //-
23502351
* bucket.setStorageClass('regional').then(function() {});
23512352
*/
2352-
setStorageClass(storageClass, options, callback) {
2353+
setStorageClass(storageClass, options, callback?) {
23532354
// In case we get input like `storageClass`, convert to `storage_class`.
23542355
storageClass = storageClass.replace(/-/g, '_')
23552356
.replace(

src/file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const GS_URL_REGEXP = /^gs:\/\/([a-z0-9_.-]+)\/(.+)$/;
9292
* billed for all requests made from File object.
9393
*/
9494
export interface FileOptions {
95-
encryptionKey?: string;
95+
encryptionKey?: string|Buffer;
9696
generation?: number|string;
9797
kmsKeyName?: string;
9898
userProject?: string;
@@ -2475,7 +2475,7 @@ class File extends ServiceObject {
24752475
* //-
24762476
* file.setStorageClass('regional').then(function() {});
24772477
*/
2478-
setStorageClass(storageClass, options, callback) {
2478+
setStorageClass(storageClass, options, callback?) {
24792479
if (is.fn(options)) {
24802480
callback = options;
24812481
options = {};

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'use strict';
1818

1919
import * as arrify from 'arrify';
20-
import {Service, GoogleAuthOptions} from '@google-cloud/common';
20+
import {Service, GoogleAuthOptions, CreateOptions} from '@google-cloud/common';
2121
import {paginator} from '@google-cloud/paginator';
2222
import {promisifyAll} from '@google-cloud/promisify';
2323
import * as extend from 'extend';
@@ -38,7 +38,8 @@ export interface StorageOptions extends GoogleAuthOptions {
3838
promise?: typeof Promise;
3939
}
4040

41-
export interface BucketOptions {
41+
export interface BucketOptions extends CreateOptions {
42+
location?: string;
4243
kmsKeyName?: string;
4344
userProject?: string;
4445
}
@@ -558,7 +559,7 @@ class Storage extends Service {
558559
* region_tag:storage_list_buckets
559560
* Another example:
560561
*/
561-
getBuckets(query, callback) {
562+
getBuckets(query, callback?) {
562563
if (!callback) {
563564
callback = query;
564565
query = {};
@@ -640,7 +641,7 @@ class Storage extends Service {
640641
* const apiResponse = data[1];
641642
* });
642643
*/
643-
getServiceAccount(options, callback) {
644+
getServiceAccount(options, callback?) {
644645
if (!callback) {
645646
callback = options;
646647
options = {};
@@ -719,3 +720,5 @@ promisifyAll(Storage, {
719720
* Full quickstart example:
720721
*/
721722
export {Storage};
723+
724+
export {Bucket, File, Channel};

0 commit comments

Comments
 (0)