Skip to content

refactor(go): Updated handler to output_executable_name for go workflows #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws_lambda_builders/workflows/go_dep/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self,
**kwargs)

options = kwargs["options"] if "options" in kwargs else {}
handler = options.get("handler", None)
handler = options.get("artifact_executable_name", None)

if osutils is None:
osutils = OSUtils()
Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_builders/workflows/go_modules/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self,
osutils = OSUtils()

options = kwargs.get("options") or {}
handler = options.get("handler", None)
handler = options.get("artifact_executable_name", None)

output_path = osutils.joinpath(artifacts_dir, handler)

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/workflows/go_dep/test_go_dep.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_builds_project_with_no_deps(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "Gopkg.toml"),
runtime=self.runtime,
options={"handler": "main"})
options={"artifact_executable_name": "main"})

expected_files = {"main"}
output_files = set(os.listdir(self.artifacts_dir))
Expand All @@ -49,7 +49,7 @@ def test_builds_project_with_no_gopkg_file(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "Gopkg.toml"),
runtime=self.runtime,
options={"handler": "main"})
options={"artifact_executable_name": "main"})

self.assertEquals(
"GoDepBuilder:DepEnsure - Exec Failed: could not find project Gopkg.toml," +
Expand All @@ -62,7 +62,7 @@ def test_builds_project_with_remote_deps(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "Gopkg.toml"),
runtime=self.runtime,
options={"handler": "main"})
options={"artifact_executable_name": "main"})

expected_files = {"main"}
output_files = set(os.listdir(self.artifacts_dir))
Expand All @@ -76,7 +76,7 @@ def test_builds_project_with_failed_remote_deps(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "Gopkg.toml"),
runtime=self.runtime,
options={"handler": "main"})
options={"artifact_executable_name": "main"})

# The full message is super long, so part of it is fine.
self.assertNotEqual(str(ex.exception).find('unable to deduce repository and source type for'), -1)
6 changes: 3 additions & 3 deletions tests/integration/workflows/go_modules/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_builds_project_without_dependencies(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "go.mod"),
runtime=self.runtime,
options={"handler": "no-deps-main"})
options={"artifact_executable_name": "no-deps-main"})
expected_files = {"no-deps-main"}
output_files = set(os.listdir(self.artifacts_dir))
print(output_files)
Expand All @@ -43,7 +43,7 @@ def test_builds_project_with_dependencies(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "go.mod"),
runtime=self.runtime,
options={"handler": "with-deps-main"})
options={"artifact_executable_name": "with-deps-main"})
expected_files = {"with-deps-main"}
output_files = set(os.listdir(self.artifacts_dir))
self.assertEquals(expected_files, output_files)
Expand All @@ -54,6 +54,6 @@ def test_fails_if_modules_cannot_resolve_dependencies(self):
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir,
os.path.join(source_dir, "go.mod"),
runtime=self.runtime,
options={"handler": "failed"})
options={"artifact_executable_name": "failed"})
self.assertIn("GoModulesBuilder:Build - Builder Failed: ",
str(ctx.exception))
6 changes: 5 additions & 1 deletion tests/unit/workflows/go_dep/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ class TestGoDepWorkflow(TestCase):
"""

def test_workflow_sets_up_workflow(self):
workflow = GoDepWorkflow("source", "artifacts", "scratch", "manifest", options={"handler": "foo"})
workflow = GoDepWorkflow("source",
"artifacts",
"scratch",
"manifest",
options={"artifact_executable_name": "foo"})
self.assertEqual(len(workflow.actions), 2)
self.assertIsInstance(workflow.actions[0], DepEnsureAction)
self.assertIsInstance(workflow.actions[1], GoBuildAction)
2 changes: 1 addition & 1 deletion tests/unit/workflows/go_modules/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def test_workflow_sets_up_builder_actions(self):
workflow = GoModulesWorkflow(
"source", "artifacts", "scratch_dir", "manifest",
runtime="go1.x",
options={"handler": "main"})
options={"artifact_executable_name": "main"})
self.assertEqual(len(workflow.actions), 1)
self.assertIsInstance(workflow.actions[0], GoModulesBuildAction)