Skip to content

Commit

Permalink
feat: Refactor create database options schema to accept array (#1578)
Browse files Browse the repository at this point in the history
* refactor: change type string -> string | string[]

because logic for createDatabase() allows string[]

* chore: add test for array style schema filed

Co-authored-by: Takuma Katsumata <tk.30.r.h@gmail.com>
  • Loading branch information
asthamohta and winor30 authored Mar 8, 2022
1 parent d21b980 commit b1c88ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface CreateDatabaseOptions
extends databaseAdmin.spanner.admin.database.v1.ICreateDatabaseRequest {
poolOptions?: SessionPoolOptions;
poolCtor?: SessionPool;
schema?: string;
schema?: string | string[];
gaxOptions?: CallOptions;
}
export type GetDatabasesOptions = PagedOptions;
Expand Down
16 changes: 16 additions & 0 deletions test/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,22 @@ describe('Instance', () => {

instance.createDatabase(NAME, options, assert.ifError);
});

it('should arrify and rename to extraStatements from array style schema filed', done => {
const SCHEMA = ['schema', 'schema2'];

const options = extend({}, OPTIONS, {
schema: SCHEMA,
});

instance.request = config => {
assert.deepStrictEqual(config.reqOpts.extraStatements, SCHEMA);
assert.strictEqual(config.reqOpts.schema, undefined);
done();
};

instance.createDatabase(NAME, options, assert.ifError);
});
});

describe('error', () => {
Expand Down

0 comments on commit b1c88ac

Please sign in to comment.