1717#include " paimon/write_context.h"
1818
1919#include " gtest/gtest.h"
20+ #include " paimon/executor.h"
21+ #include " paimon/memory/memory_pool.h"
2022#include " paimon/result.h"
2123#include " paimon/status.h"
24+ #include " paimon/testing/mock/mock_file_system.h"
2225#include " paimon/testing/utils/testharness.h"
2326
2427namespace paimon ::test {
@@ -41,11 +44,41 @@ TEST(WriteContextTest, TestSimple) {
4144 ASSERT_TRUE (ctx->GetFileSystemSchemeToIdentifierMap ().empty ());
4245}
4346
44- TEST (WriteContextTest, TestWithTempDirectory ) {
47+ TEST (WriteContextTest, TestAllWithMethods ) {
4548 WriteContextBuilder builder (" table_root_path" , " commit_user_1" );
4649
47- ASSERT_OK_AND_ASSIGN (auto ctx, builder.WithTempDirectory (" /tmp" ).Finish ());
48- ASSERT_EQ (ctx->GetTempDirectory (), " /tmp" );
50+ auto memory_pool = GetDefaultPool ();
51+ std::shared_ptr<Executor> executor = CreateDefaultExecutor ();
52+ auto file_system = std::make_shared<MockFileSystem>();
53+ std::vector<std::string> write_schema = {" f0" , " f1" };
54+ std::map<std::string, std::string> fs_scheme_to_identifier_map = {{" file" , " local" },
55+ {" oss" , " jindo" }};
56+
57+ ASSERT_OK_AND_ASSIGN (auto ctx,
58+ builder.WithStreamingMode (true )
59+ .WithIgnoreNumBucketCheck (true )
60+ .WithIgnorePreviousFiles (true )
61+ .WithMemoryPool (memory_pool)
62+ .WithExecutor (executor)
63+ .WithTempDirectory (" /tmp/with-all" )
64+ .WithWriteId (123 )
65+ .WithBranch (" test_branch" )
66+ .WithWriteSchema (write_schema)
67+ .WithFileSystemSchemeToIdentifierMap (fs_scheme_to_identifier_map)
68+ .WithFileSystem (file_system)
69+ .Finish ());
70+
71+ ASSERT_TRUE (ctx->IsStreamingMode ());
72+ ASSERT_TRUE (ctx->IgnoreNumBucketCheck ());
73+ ASSERT_TRUE (ctx->IgnorePreviousFiles ());
74+ ASSERT_EQ (ctx->GetMemoryPool (), memory_pool);
75+ ASSERT_EQ (ctx->GetExecutor (), executor);
76+ ASSERT_EQ (ctx->GetTempDirectory (), " /tmp/with-all" );
77+ ASSERT_EQ (ctx->GetWriteId (), 123 );
78+ ASSERT_EQ (ctx->GetBranch (), " test_branch" );
79+ ASSERT_EQ (ctx->GetWriteSchema (), write_schema);
80+ ASSERT_EQ (ctx->GetFileSystemSchemeToIdentifierMap (), fs_scheme_to_identifier_map);
81+ ASSERT_EQ (ctx->GetSpecificFileSystem (), file_system);
4982}
5083
5184} // namespace paimon::test
0 commit comments