Skip to content

Commit

Permalink
fix(typescript): make SetLabelOptions optional (#766)
Browse files Browse the repository at this point in the history
* test(bucket): location type system tests
* docs(bucket): add verbiage about deprecated storage classes
  • Loading branch information
callmehiphop committed Jul 16, 2019
1 parent 99e3b17 commit 4336882
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
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
): 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`
* 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
40 changes: 40 additions & 0 deletions system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,46 @@ 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));
await bucket.removeRetentionPeriod();
});

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

0 comments on commit 4336882

Please sign in to comment.