Skip to content

Commit 75456a4

Browse files
committed
fix: Review comments
1 parent 17f89c7 commit 75456a4

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

tests/builder.test.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,13 @@ TEST(Builder, ReadIngredientFile)
743743
// Use target/tmp like other tests
744744
fs::path temp_dir = "target/tmp";
745745

746+
// Remove and recreate the target/tmp folder before using it
747+
// This is technically a clean-up in-between tests
748+
if (fs::exists(temp_dir)) {
749+
fs::remove_all(temp_dir);
750+
}
751+
fs::create_directories(temp_dir);
752+
746753
// Test that the function can read ingredient file successfully
747754
std::string result;
748755
ASSERT_NO_THROW(result = c2pa::read_ingredient_file(source_path, temp_dir));
@@ -785,6 +792,13 @@ TEST(Builder, ReadIngredientFileWhoHasAManifestStore)
785792
// Use target/tmp like other tests
786793
fs::path temp_dir = "target/tmp";
787794

795+
// Remove and recreate the target/tmp folder before using it
796+
// This is technically a clean-up in-between tests
797+
if (fs::exists(temp_dir)) {
798+
fs::remove_all(temp_dir);
799+
}
800+
fs::create_directories(temp_dir);
801+
788802
// Test that the function can read ingredient file successfully
789803
std::string result;
790804
ASSERT_NO_THROW(result = c2pa::read_ingredient_file(source_path, temp_dir));
@@ -841,9 +855,15 @@ TEST(Builder, AddIngredientAsResourceToBuilder)
841855
fs::path ingredient_source_path = current_dir / "../tests/fixtures/A.jpg";
842856
std::string ingredient_source_path_str = ingredient_source_path.string();
843857

844-
// Use target/tmp like other tests
845858
fs::path temp_dir = current_dir / "../build/ingredient_as_resource_temp_dir";
846859

860+
// Remove and recreate the build/ingredient_as_resource_temp_dir folder before using it
861+
// This is technically a clean-up in-between tests
862+
if (fs::exists(temp_dir)) {
863+
fs::remove_all(temp_dir);
864+
}
865+
fs::create_directories(temp_dir);
866+
847867
// Get the needed JSON for the ingredient from the ingredient file using `read_ingredient_file`
848868
std::string result;
849869
// The data_dir is the location where binary resources will be stored
@@ -914,6 +934,13 @@ TEST(Builder, AddIngredientToBuilderUsingBasePath)
914934
// Use target/tmp like other tests
915935
fs::path temp_dir = current_dir / "../build/ingredient_as_resource_temp_dir";
916936

937+
// Remove and recreate the build/ingredient_as_resource_temp_dir folder before using it
938+
// This is technically a clean-up in-between tests
939+
if (fs::exists(temp_dir)) {
940+
fs::remove_all(temp_dir);
941+
}
942+
fs::create_directories(temp_dir);
943+
917944
// Get the needed JSON for the ingredient
918945
std::string result;
919946
// The data_dir is the location where binary resources will be stored
@@ -970,6 +997,13 @@ TEST(Builder, AddIngredientWithProvenanceDataToBuilderUsingBasePath)
970997
// Use target/tmp like other tests
971998
fs::path temp_dir = current_dir / "../build/ingredient_as_resource_temp_dir";
972999

1000+
// Remove and recreate the build/ingredient_as_resource_temp_dir folder before using it
1001+
// This is technically a clean-up in-between tests
1002+
if (fs::exists(temp_dir)) {
1003+
fs::remove_all(temp_dir);
1004+
}
1005+
fs::create_directories(temp_dir);
1006+
9731007
// Get the needed JSON for the ingredient
9741008
std::string result;
9751009
// The data_dir is the location where binary resources will be stored

0 commit comments

Comments
 (0)