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

fix(typescript): make SetLabelOptions optional #766

Merged
merged 4 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ class Bucket extends ServiceObject {

setLabels(
labels: Labels,
options: SetLabelsOptions
options?: SetLabelsOptions
callmehiphop marked this conversation as resolved.
Show resolved Hide resolved
): Promise<SetLabelsResponse>;
setLabels(labels: Labels, callback: SetLabelsCallback): void;
setLabels(
Expand Down Expand Up @@ -2752,9 +2752,10 @@ class Bucket extends ServiceObject {
*
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
*
* @param {string} storageClass The new storage class. (`multi_regional`,
* `regional`, `standard`, `nearline`, `coldline`, or
* `durable_reduced_availability`)
* @param {string} storageClass The new storage class. (`standard`,
* `nearline`, `coldline`, or `durable_reduced_availability`).
* **Note:** The legacy storage classes `multi_regional` and `regional`
callmehiphop marked this conversation as resolved.
Show resolved Hide resolved
* have been deprecated.
* @param {object} [options] Configuration options.
* @param {string} [options.userProject] - The ID of the project which will be
* billed for the request.
Expand Down
43 changes: 43 additions & 0 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,49 @@ describe('storage', () => {
assert.strictEqual(metadata.storageClass, 'MULTI_REGIONAL');
});

describe('locationType', () => {
const types = [
'multi-region',
'region',
'dual-region',
];

beforeEach(() => {
delete bucket.metadata;
});

it('should be available from getting a bucket', async () => {
const [metadata] = await bucket.getMetadata();
assert(types.includes(metadata.locationType));
});

it('should be available from creating a bucket', async () => {
const [bucket] = await storage.createBucket(generateName());
assert(types.includes(bucket.metadata.locationType));
return bucket.delete();
});

it('should be available from listing buckets', async () => {
const [buckets] = await storage.getBuckets();

assert(buckets.length > 0);

buckets.forEach(bucket => {
assert(types.includes(bucket.metadata.locationType));
});
});

it('should be available from setting retention policy', async () => {
await bucket.setRetentionPeriod(RETENTION_DURATION_SECONDS);
assert(types.includes(bucket.metadata.locationType));
});

it('should be available from updating a bucket', async () => {
await bucket.setLabels({a: 'b'});
assert(types.includes(bucket.metadata.locationType));
});
});

describe('labels', () => {
const LABELS = {
label: 'labelvalue', // no caps or spaces allowed (?)
Expand Down