Skip to content

Commit

Permalink
dataSource property is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Sep 4, 2024
1 parent 47605c2 commit ff0037a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/@aws-cdk/aws-location-alpha/lib/place-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ export interface PlaceIndexProps {

/**
* Data source for the place index
*
* @default DataSource.ESRI
*/
readonly dataSource?: DataSource;
readonly dataSource: DataSource;

/**
* Intend use for the results of an operation
Expand Down Expand Up @@ -159,7 +157,7 @@ export class PlaceIndex extends PlaceIndexBase {
*/
public readonly placeIndexUpdateTime: string;

constructor(scope: Construct, id: string, props: PlaceIndexProps = {}) {
constructor(scope: Construct, id: string, props: PlaceIndexProps) {
if (props.description && !Token.isUnresolved(props.description) && props.description.length > 1000) {
throw new Error(`\`description\` must be between 0 and 1000 characters. Received: ${props.description.length} characters`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { App, Stack } from 'aws-cdk-lib';
import * as integ from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import { PlaceIndex } from '../lib';
import { DataSource, PlaceIndex } from '../lib';

class TestStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);

new PlaceIndex(this, 'PlaceIndex');
new PlaceIndex(this, 'PlaceIndex', {
dataSource: DataSource.ESRI,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ beforeEach(() => {
});

test('create a place index', () => {
new PlaceIndex(stack, 'PlaceIndex');
new PlaceIndex(stack, 'PlaceIndex', {
dataSource: DataSource.ESRI,
});

Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', {
DataSource: 'Esri',
Expand All @@ -21,6 +23,7 @@ test('create a place index', () => {
test('create a place index with description', () => {
new PlaceIndex(stack, 'PlaceIndex', {
description: 'my-description',
dataSource: DataSource.ESRI,
});

Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', {
Expand All @@ -33,6 +36,7 @@ test('create a place index with description', () => {
test('creates a place index with empty description', () => {
new PlaceIndex(stack, 'PlaceIndex', {
description: '',
dataSource: DataSource.ESRI,
});

Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', {
Expand All @@ -43,12 +47,14 @@ test('creates a place index with empty description', () => {
test('throws with invalid description', () => {
expect(() => new PlaceIndex(stack, 'PlaceIndex', {
description: 'a'.repeat(1001),
dataSource: DataSource.ESRI,
})).toThrow('`description` must be between 0 and 1000 characters. Received: 1001 characters');
});

test('throws with invalid name', () => {
expect(() => new PlaceIndex(stack, 'PlaceIndex', {
placeIndexName: 'inv@lid',
dataSource: DataSource.ESRI,
})).toThrow(/Invalid place index name/);
});

Expand Down

0 comments on commit ff0037a

Please sign in to comment.