diff --git a/src/index.ts b/src/index.ts index 92c94b8..0483790 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,22 @@ -export class Hello { - public sayHello() { - return 'hello, world!'; +import * as crypto from 'crypto'; + +// Default +// None (stack auto generate) +// string + +// export interface Xxx { +// readonly naming: Naming | {functionName: string, roleName: string}; +// } + +export namespace ResourceNaming { + export enum NamingType { + DEFAULT, + NONE, } -} \ No newline at end of file + + export function createRandomString(value: crypto.BinaryLike, length: number = 8) { + return crypto.createHash('shake256', { outputLength: (length / 2) }) + .update(value) + .digest('hex'); + } +} diff --git a/test/hello.test.ts b/test/hello.test.ts deleted file mode 100644 index acbacd4..0000000 --- a/test/hello.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Hello } from '../src'; - -test('hello', () => { - expect(new Hello().sayHello()).toBe('hello, world!'); -}); \ No newline at end of file diff --git a/test/naming.test.ts b/test/naming.test.ts new file mode 100644 index 0000000..41f35c7 --- /dev/null +++ b/test/naming.test.ts @@ -0,0 +1,22 @@ +import { ResourceNaming } from '../src'; + +describe('ResouceNaming Testing', () => { + + const naming = ((namingType: ResourceNaming.NamingType): string | undefined => { + switch (namingType) { + case ResourceNaming.NamingType.DEFAULT: + const random = ResourceNaming.createRandomString('ResourceName'); + return `resource-name-${random}`; + case ResourceNaming.NamingType.NONE: + return undefined; + } + }); + + it('Is Naming Randmon String', () => { + expect(typeof naming(ResourceNaming.NamingType.DEFAULT)).toBe('string'); + }); + + it('Is Naming undefined', () => { + expect(naming(ResourceNaming.NamingType.NONE)).toBeUndefined(); + }); +}); \ No newline at end of file