-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1235 from hashicorp/improve-provider-generation-t…
…ests test(cli): test generated providers
- Loading branch information
Showing
21 changed files
with
489 additions
and
84 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
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
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
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,35 @@ | ||
#!/usr/bin/python3 -tt | ||
from constructs import Construct | ||
from cdktf import App, TerraformStack, Testing, TerraformOutput | ||
from imports.docker import Image, Container, DockerProvider | ||
|
||
class References(TerraformStack): | ||
def __init__(self, scope: Construct, ns: str): | ||
super().__init__(scope, ns) | ||
|
||
DockerProvider(self, "provider") | ||
|
||
docker_image = Image(self, 'nginxImage', name='nginx:latest', keep_locally=False) | ||
|
||
# Simple References | ||
container = Container(self, 'nginxContainer', name='nginx-python-cdktf', | ||
image=docker_image.repo_digest, ports=[ | ||
{ | ||
'internal': 80, | ||
'external': 8000 | ||
}], privileged=False) | ||
# Single-item References | ||
TerraformOutput(self, "containerCapAdd", value=container.capabilities.add) | ||
|
||
# Direct Mutation | ||
docker_image.keep_locally = True | ||
|
||
# Reference Mutation | ||
container.privileged = docker_image.keep_locally | ||
|
||
|
||
|
||
app = Testing.stub_version(App(stack_traces=False)) | ||
References(app, "references") | ||
|
||
app.synth() |
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,43 @@ | ||
import { TestDriver } from "../../test-helper"; | ||
|
||
describe("python full integration 3rd party", () => { | ||
let driver: TestDriver; | ||
|
||
beforeAll(async () => { | ||
driver = new TestDriver(__dirname); | ||
await driver.setupPythonProject(); | ||
await driver.synth(); | ||
}); | ||
|
||
test("synth generates JSON", async () => { | ||
expect(driver.synthesizedStack("references").toString()).toMatchSnapshot(); | ||
}); | ||
|
||
describe("references", () => { | ||
test("simple references", () => { | ||
expect( | ||
driver.synthesizedStack("references").byId("nginxContainer").image | ||
).toContain("nginxImage.repo_digest"); | ||
}); | ||
|
||
test("single-item references", () => { | ||
expect( | ||
driver.synthesizedStack("references").output("containerCapAdd") | ||
).toContain("nginxContainer.capabilities[0].add"); | ||
}); | ||
}); | ||
|
||
describe("mutation", () => { | ||
test("direct mutation", () => { | ||
expect( | ||
driver.synthesizedStack("references").byId("nginxImage").keep_locally | ||
).toBeTruthy(); | ||
}); | ||
|
||
test("reference mutation", () => { | ||
expect( | ||
driver.synthesizedStack("references").byId("nginxContainer").privileged | ||
).toContain("nginxImage.keep_locally"); | ||
}); | ||
}); | ||
}); |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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.