新家db.meta的索引相关接口

This commit is contained in:
huzhongying
2022-03-08 11:37:29 +08:00
parent 01af68cd0d
commit f769863ed7
6 changed files with 205 additions and 9 deletions

View File

@@ -13,13 +13,13 @@ import cn.hutool.db.ds.DSFactory;
/**
* 元数据信息单元测试
*
*
* @author Looly
*
*/
public class MetaUtilTest {
DataSource ds = DSFactory.get("test");
@Test
public void getTablesTest() {
List<String> tables = MetaUtil.getTables(ds);
@@ -31,10 +31,16 @@ public class MetaUtilTest {
Table table = MetaUtil.getTableMeta(ds, "user");
Assert.assertEquals(CollectionUtil.newHashSet("id"), table.getPkNames());
}
@Test
public void getColumnNamesTest() {
String[] names = MetaUtil.getColumnNames(ds, "user");
Assert.assertArrayEquals(StrUtil.splitToArray("id,name,age,birthday,gender", ','), names);
}
@Test
public void getTableIndexInfoTest() {
Table table = MetaUtil.getTableMeta(ds, "user_1");
Assert.assertEquals(table.getIndexInfoList().size(), 2);
}
}