1 Star 0 Fork 0

廖永煌/lyh

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
br_438.diff 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
廖永煌 提交于 2025-02-08 15:52 +08:00 . 12
diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
index 11d630522..425ed00d1 100644
--- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
+++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
@@ -1838,6 +1838,45 @@ HWTEST_F(DistributedDBRDBCollaborationTest, NormalSync018, TestSize.Level0)
EXPECT_EQ(changeData[tableName].field.size(), 1u); // rowid
}
+/**
+ * @tc.name: NormalSync020
+ * @tc.desc: Test set distributed schema after recreating the table.
+ * @tc.type: FUNC
+ * @tc.require:
+ * @tc.author: liaoyonghuang
+ */
+HWTEST_F(DistributedDBRDBCollaborationTest, NormalSync020, TestSize.Level0)
+{
+ /**
+ * @tc.steps: step1. Create device table and cloud table in COLLABORATION
+ * @tc.expected: step1.ok
+ */
+ ASSERT_NO_FATAL_FAILURE(InitDelegate());
+ auto schema = GetSchema();
+ auto distributedSchema = RDBDataGenerator::ParseSchema(schema, true);
+ EXPECT_EQ(delegate_->CreateDistributedTable(DEVICE_SYNC_TABLE, TableSyncType::DEVICE_COOPERATION), OK);
+ deviceB_->SetDistributedSchema(distributedSchema);
+ EXPECT_EQ(delegate_->SetDistributedSchema(distributedSchema), OK);
+ /**
+ * @tc.steps: step2. Sync a piece of data
+ * @tc.expected: step2.ok
+ */
+ auto tableSchema = GetTableSchema();
+ ASSERT_EQ(RDBDataGenerator::InsertVirtualLocalDBData(0, 1, deviceB_, tableSchema), E_OK);
+ ASSERT_EQ(RDBDataGenerator::PrepareVirtualDeviceEnv(tableSchema.name, db_, deviceB_), E_OK);
+ Query query = Query::Select(tableSchema.name);
+ DistributedDBToolsUnitTest::BlockSync(*delegate_, query, SYNC_MODE_PULL_ONLY, OK, {deviceB_->GetDeviceId()});
+ /**
+ * @tc.steps: step3. Recreate table and set distributed schema.
+ * @tc.expected: step3.ok
+ */
+ std::string sql = std::string("drop table ").append(DEVICE_SYNC_TABLE);
+ EXPECT_EQ(SQLiteUtils::ExecuteRawSQL(db_, sql), E_OK);
+ RDBDataGenerator::InitTable(schema.tables.front(), false, *db_);
+ EXPECT_EQ(delegate_->CreateDistributedTable(DEVICE_SYNC_TABLE, TableSyncType::DEVICE_COOPERATION), OK);
+ EXPECT_EQ(delegate_->SetDistributedSchema(distributedSchema), OK);
+}
+
/**
* @tc.name: InvalidSync001
* @tc.desc: Test remote set empty distributed schema and sync.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liao-yonghuang/lyh.git
git@gitee.com:liao-yonghuang/lyh.git
liao-yonghuang
lyh
lyh
master

搜索帮助