Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bin/*
obj/*
build/*
Debug/*
.vs/

*.layout
*.depend
Expand Down
21 changes: 21 additions & 0 deletions src/tests/tool1cd/test_saveconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,26 @@ TEST_CASE("Сохранение конфигураций в 8.3.8", "[tool1cd][C
boost::filesystem::remove(cfpath);
}

}

GIVEN("База tests/db838/db02/1Cv8.1CD") {
std::string dbpath(CMAKE_SOURCE_DIR);
dbpath += "/tests/db838/db02/1Cv8.1CD";

T_1CD base1CD(dbpath, nullptr, true);

WHEN("Выгружаем конфигурации поставщиков") {
for (auto& supplier_config : base1CD.supplier_configs()) {
path cfpath = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
supplier_config->save_to_file(cfpath);

std::string then_result = std::string( "Получаем файл для " + supplier_config->name() );
THEN( then_result ) {
REQUIRE(boost::filesystem::exists(cfpath));
}
boost::filesystem::remove(cfpath);
}
}

}
}
44 changes: 20 additions & 24 deletions src/tool1cd/SupplierConfigBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ string NODE_GENERAL() {
SupplierConfigBuilder::SupplierConfigBuilder(TableFile *table_file)
: _table_file(table_file)
{
create_main_catalog();
std::unique_ptr<ContainerFile> container_file( new ContainerFile(_table_file, _table_file->name) );
if(!container_file->open()) {
throw SupplierConfigReadException("Ошибка открытия конейнера файлов")
.add_detail("Имя", container_file->name);
}

TStream *out_stream = new TTempStream;

try {
ZInflateStream(container_file->stream, out_stream);
}
catch(ZError) {
throw SupplierConfigReadException("Ошибка распаковки конфигурации поставщика")
.add_detail("Таблица", _table_file->t->getname())
.add_detail("Имя", _table_file->name);
}

container_file->close();

main_catalog = std::unique_ptr<V8Catalog>( new V8Catalog(out_stream, true) );
}

std::shared_ptr<SupplierConfig> SupplierConfigBuilder::build() {
Expand Down Expand Up @@ -117,29 +136,6 @@ std::shared_ptr<SupplierConfig> SupplierConfigBuilder::build() {
return sup_conf;
}

void SupplierConfigBuilder::create_main_catalog() {
std::unique_ptr<ContainerFile> container_file( new ContainerFile(_table_file, _table_file->name) );
if(!container_file->open()) {
throw SupplierConfigReadException("Ошибка открытия конейнера файлов")
.add_detail("Имя", container_file->name);
}

std::unique_ptr<TStream> out_stream( new TTempStream );

try {
ZInflateStream(container_file->stream, out_stream.get());
}
catch(ZError) {
throw SupplierConfigReadException("Ошибка распаковки конфигурации поставщика")
.add_detail("Таблица", _table_file->t->getname())
.add_detail("Имя", _table_file->name);
}

container_file->close();

main_catalog.reset( new V8Catalog(out_stream.get(), true) );
}

int32_t SupplierConfigBuilder::get_version() const {
V8File* version_file = main_catalog->GetFile("version");
if(!version_file) {
Expand Down
1 change: 0 additions & 1 deletion src/tool1cd/SupplierConfigBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class SupplierConfigBuilder
TableFile *_table_file {nullptr};
std::unique_ptr<V8Catalog> main_catalog;

void create_main_catalog();
int32_t get_version() const;
V8File* get_file(const std::string &file_name) const;

Expand Down
Binary file added tests/db838/db02/1Cv8.1CD
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/db838/db02/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
База данных для тестировани работы с конфигурацией поставщика

Название конфигурации: VendorsConfig
Версия: 1.1
Binary file added tests/db838/db02/source_db/1Cv8.1CD
Binary file not shown.
1 change: 1 addition & 0 deletions tests/db838/db02/source_db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
База данных для создания файлов поставки