-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chang Zhe Jiet
authored and
Chang Zhe Jiet
committed
Mar 28, 2024
1 parent
b975c8e
commit a09f737
Showing
10 changed files
with
773 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Argument, Attribute } from '../arguments'; | ||
import { Util } from '../utils'; | ||
import { Block, Resource } from '.'; | ||
|
||
/** | ||
* @category Block | ||
*/ | ||
export interface MovedArgs { | ||
from: Argument; | ||
to: Argument | Resource; | ||
} | ||
|
||
/** | ||
* @category Block | ||
*/ | ||
export class Moved extends Block<MovedArgs> { | ||
|
||
/** | ||
* Construct moved. | ||
* | ||
* Refer to Terraform documentation on what can be put as arguments. | ||
* | ||
* @param args arguments | ||
*/ | ||
constructor(args: MovedArgs) { | ||
super('moved', [], args); | ||
} | ||
|
||
override asArgument(): Argument { | ||
throw Util.inaccessibleMethod(); | ||
} | ||
|
||
override attr(_name: string): Attribute { | ||
throw Util.inaccessibleMethod(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Argument, Attribute } from '../arguments'; | ||
import { Util } from '../utils'; | ||
import { Block } from '.'; | ||
|
||
/** | ||
* @category Block | ||
*/ | ||
export interface RemovedArgs { | ||
from: Argument; | ||
lifecycle: { | ||
destroy: boolean; | ||
}; | ||
} | ||
|
||
/** | ||
* @category Block | ||
*/ | ||
export class Removed extends Block<RemovedArgs> { | ||
|
||
/** | ||
* Construct removed. | ||
* | ||
* Refer to Terraform documentation on what can be put as arguments. | ||
* | ||
* @param args arguments | ||
*/ | ||
constructor(args: RemovedArgs) { | ||
super('removed', [], args); | ||
} | ||
|
||
override asArgument(): Argument { | ||
throw Util.inaccessibleMethod(); | ||
} | ||
|
||
override attr(_name: string): Attribute { | ||
throw Util.inaccessibleMethod(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { arg } from '../../src/arguments'; | ||
import { Moved, Resource } from '../../src/blocks'; | ||
|
||
test('To argument', () => { | ||
const moved = new Moved({ | ||
from: arg('resource.a'), | ||
to: arg('resource.b') | ||
}); | ||
expect(moved.toTerraform()).toMatchSnapshot(); | ||
expect(() => moved.asArgument()).toThrow(); | ||
expect(() => moved.attr('attr')).toThrow(); | ||
}); | ||
|
||
test('To resource', () => { | ||
const resource = new Resource('resource', 'b'); | ||
const moved = new Moved({ | ||
from: arg('resource.a'), | ||
to: resource | ||
}); | ||
expect(moved.toTerraform()).toMatchSnapshot(); | ||
expect(() => moved.asArgument()).toThrow(); | ||
expect(() => moved.attr('attr')).toThrow(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { arg } from '../../src/arguments'; | ||
import { Removed } from '../../src/blocks'; | ||
|
||
test('Removed', () => { | ||
const moved = new Removed({ | ||
from: arg('resource.a'), | ||
lifecycle: { | ||
destroy: false | ||
} | ||
}); | ||
expect(moved.toTerraform()).toMatchSnapshot(); | ||
expect(() => moved.asArgument()).toThrow(); | ||
expect(() => moved.attr('attr')).toThrow(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`To argument 1`] = ` | ||
"moved{ | ||
from = resource.a | ||
to = resource.b | ||
} | ||
" | ||
`; | ||
|
||
exports[`To resource 1`] = ` | ||
"moved{ | ||
from = resource.a | ||
to = resource.b | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Removed 1`] = ` | ||
"removed{ | ||
from = resource.a | ||
lifecycle { | ||
destroy = false | ||
} | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.