diff options
| -rw-r--r-- | zenstore/filecas.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index a37450cd8..d8811de00 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -15,6 +15,11 @@ #include <zencore/uid.h> #include <zenstore/basicfile.h> +#if ZEN_WITH_TESTS +# include <zencore/compactbinarybuilder.h> +# include <zenstore/gc.h> +#endif + #include <gsl/gsl-lite.hpp> #include <barrier> @@ -489,7 +494,8 @@ TEST_CASE("cas.file.move") { using namespace fmt::literals; - ScopedTemporaryDirectory TempDir{"d:\\filecas_testdir"}; + // specifying an absolute path here can be helpful when using procmon to dig into things + ScopedTemporaryDirectory TempDir; // {"d:\\filecas_testdir"}; CasStoreConfiguration CasConfig; CasConfig.RootDirectory = TempDir.Path() / "cas"; @@ -564,6 +570,34 @@ TEST_CASE("cas.file.move") # endif } +TEST_CASE("cas.file.gc") +{ + // specifying an absolute path here can be helpful when using procmon to dig into things + ScopedTemporaryDirectory TempDir; // {"d:\\filecas_testdir"}; + + CasStoreConfiguration CasConfig; + CasConfig.RootDirectory = TempDir.Path() / "cas"; + + FileCasStrategy FileCas(CasConfig); + + for (int i = 0; i < 1000; ++i) + { + CbObjectWriter Cbo; + Cbo << "id" << i; + CbObject Obj = Cbo.Save(); + + IoBuffer ObjBuffer = Obj.GetBuffer().AsIoBuffer(); + IoHash Hash = HashBuffer(ObjBuffer); + + FileCas.InsertChunk(ObjBuffer, Hash); + ; + } + + GcContext Ctx; + + FileCas.GarbageCollect(Ctx); +} + #endif void |