sparse-intern-71089
06/14/2023, 8:33 PMfierce-xylophone-92490
06/14/2023, 8:35 PMdef create_repo_pulumi_program():
_create_repo(repo_config=...)
stack = auto.create_or_select_stack(
project_name=project_name,
stack_name=stack_name,
program=create_repo_pulumi_program,
)
stack.set_config(key="github:owner", value=auto.ConfigValue(repo.owner, secret=False))
stack.up(on_output=print)
little-cartoon-10569
06/14/2023, 8:36 PMlittle-cartoon-10569
06/14/2023, 8:37 PMlittle-cartoon-10569
06/14/2023, 8:38 PMfierce-xylophone-92490
06/14/2023, 8:53 PM_create_repo()
as a unit, are you saying I could modify my _create_repo()
function to do something like this
def _create_repo(repo_config: GithubRepoConfig) -> Tuple[
github.Repository,
List[github.RepositorySecret],
List[github.ActionsEnvironment],
List[github.ActionsEnvironmentSecret],
List[github.ActionsEnvironmentVariable],
]:
...
And then basically run assertions on the returned object representations? So I imagine I'd be making statements like
repo, repo_secrets, repo_envs, repo_env_secrets, repo_env_vars = _create_repo(repo_config)
assert repo_config.repo_name == repo.repo_name
assert len(repo_config.environments) == len(repo_envs)
assert repo_config.environments[0].name == repo_envs[0].name
...
Is this kind of what you're saying?little-cartoon-10569
06/14/2023, 8:57 PMlittle-cartoon-10569
06/14/2023, 8:58 PMlittle-cartoon-10569
06/14/2023, 8:58 PMlittle-cartoon-10569
06/14/2023, 8:59 PMfierce-xylophone-92490
06/14/2023, 9:19 PMOpinionatedGithubRepo
, at that point would it make sense to attribute test that.
But in the greater context of a program, integration tests are the only way? I can totally see the value of integration tests that set up real infrastructure. They're just so slow and complex to set up.fierce-xylophone-92490
06/14/2023, 9:20 PMfierce-xylophone-92490
06/14/2023, 9:21 PMfierce-xylophone-92490
06/14/2023, 9:28 PM@pulumi.runtime.test
def test_repo_properties():
"""Test that running `stack.preview` doesn't crash."""
repo = _create_repo(GithubRepo(
name="testrepo",
owner="testowner",
description="test description",
# environments=["Sandbox", "test-dev", "test-prod"],
# admin_teams=["testteam"],
))
def check_repo_props(args):
repo_name, repo_desc = args
assert repo_name == "testrepo"
assert repo_desc == "test description"
return pulumi.Output.all(repo.name, repo.description).apply(check_repo_props)
little-cartoon-10569
06/14/2023, 9:40 PMIf I were to turn this "program" into a "class" (a pulumi component) called OpinionatedGithubRepo , at that point would it make sense to attribute test that.Yes, absolutely 🙂
little-cartoon-10569
06/14/2023, 9:41 PMI can totally see the value of integration tests that set up real infrastructure. They're just so slow and complex to set up.Pulumi has just launched Review Stacks which makes this much easier. https://www.pulumi.com/blog/review-stacks/ https://www.pulumi.com/docs/pulumi-cloud/deployments/review-stacks/
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by