Exemplo n.º 1
0
    def test_should_instantiate_first_time(self):
        with osutils.mkdir_temp() as temp_base_dir:
            build_dir = Path(temp_base_dir, ".aws-sam", "build")
            build_dir.mkdir(parents=True)
            build_graph1 = BuildGraph(str(build_dir.resolve()))
            build_graph1.clean_redundant_functions_and_update(True)

            build_graph2 = BuildGraph(str(build_dir.resolve()))

            self.assertEqual(build_graph1.get_build_definitions(), build_graph2.get_build_definitions())
Exemplo n.º 2
0
    def _get_build_graph(self):
        """
        Converts list of functions into a build graph, where we can iterate on each unique build and trigger build
        :return: BuildGraph, which represents list of unique build definitions
        """
        build_graph = BuildGraph(self._build_dir)
        functions = self._resources_to_build.functions
        for function in functions:
            build_details = BuildDefinition(function.runtime, function.codeuri, function.metadata)
            build_graph.put_build_definition(build_details, function)

        build_graph.clean_redundant_functions_and_update(not self._is_building_specific_resource)
        return build_graph
Exemplo n.º 3
0
    def test_should_instantiate_first_time_and_update(self):
        with osutils.mkdir_temp() as temp_base_dir:
            build_dir = Path(temp_base_dir, ".aws-sam", "build")
            build_dir.mkdir(parents=True)

            # create a build graph and persist it
            build_graph1 = BuildGraph(str(build_dir))
            build_definition1 = BuildDefinition(TestBuildGraph.RUNTIME, TestBuildGraph.CODEURI, TestBuildGraph.METADATA)
            function1 = generate_function(
                runtime=TestBuildGraph.RUNTIME, codeuri=TestBuildGraph.CODEURI, metadata=TestBuildGraph.METADATA
            )
            build_graph1.put_build_definition(build_definition1, function1)
            build_graph1.clean_redundant_functions_and_update(True)

            # read previously persisted graph and compare
            build_graph2 = BuildGraph(str(build_dir))
            self.assertEqual(len(build_graph1.get_build_definitions()), len(build_graph2.get_build_definitions()))
            self.assertEqual(
                list(build_graph1.get_build_definitions())[0], list(build_graph2.get_build_definitions())[0]
            )