def test_no_build(self): car = team.Car("default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", "build_command": "./gradlew assemble" }) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=None) es.prepare()
def test_raises_error_on_missing_car_variable(self): car = team.Car( "default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", # system.build_command is not defined }, ) renderer = supplier.TemplateRenderer(version="abc") builder = mock.create_autospec(supplier.Builder) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder, template_renderer=renderer) with pytest.raises( exceptions.SystemSetupError, match='Car "default" requires config key "system.build_command"' ): es.prepare() assert builder.build.call_count == 0
def test_add_elasticsearch_binary(self): es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", builder=None) binaries = {} es.add(binaries=binaries) self.assertEqual(binaries, {"elasticsearch": "elasticsearch.tar.gz"})
def test_build(self): builder = mock.create_autospec(supplier.Builder) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", builder=builder) es.prepare() builder.build.assert_called_once_with( [supplier.CLEAN_TASK, supplier.ASSEMBLE_TASK])
def test_add_elasticsearch_binary(self): car = team.Car("default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", "build_command": "./gradlew assemble", "artifact_path_pattern": "distribution/archives/tar/build/distributions/*.tar.gz" }) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=None) binaries = {} es.add(binaries=binaries) self.assertEqual(binaries, {"elasticsearch": "elasticsearch.tar.gz"})
def test_build(self): car = team.Car("default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", "build_command": "./gradlew assemble" }) builder = mock.create_autospec(supplier.Builder) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder) es.prepare() builder.build.assert_called_once_with(["./gradlew clean", "./gradlew assemble"])
def test_raises_error_on_missing_car_variable(self): car = team.Car("default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", # build_command is not defined }) builder = mock.create_autospec(supplier.Builder) es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder) with self.assertRaisesRegex(exceptions.SystemSetupError, "Car \"default\" requires config key \"build_command\"."): es.prepare() self.assertEqual(0, builder.build.call_count)
def test_add_elasticsearch_binary(self): car = team.Car( "default", root_path=None, config_paths=[], variables={ "clean_command": "./gradlew clean", "system.build_command": "./gradlew assemble", "system.artifact_path_pattern": "distribution/archives/tar/build/distributions/*.tar.gz", }, ) renderer = supplier.TemplateRenderer(version="abc") es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", car=car, builder=None, template_renderer=renderer) binaries = {} es.add(binaries=binaries) assert binaries == {"elasticsearch": "elasticsearch.tar.gz"}
def test_no_build(self): es = supplier.ElasticsearchSourceSupplier(revision="abc", es_src_dir="/src", remote_url="", builder=None) es.prepare()