From a3a480a0a11e0b5a5ea1c0a9325eebe91973d70b Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 8 Aug 2023 18:19:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E5=88=9D=E5=A7=8B=E7=BB=84=E7=BB=87=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1012653 --user=王孝刚 系统设置-组织-项目-后台 https://www.tapd.cn/55049933/s/1401306 --- .../OrganizationProjectControllerTests.java | 5 +++++ .../src/test/resources/dml/init_org_project.sql | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 backend/services/system-setting/src/test/resources/dml/init_org_project.sql diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java index f84eb051b3..8cb8995741 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java @@ -29,6 +29,8 @@ import org.junit.jupiter.api.*; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultMatcher; @@ -168,6 +170,9 @@ public class OrganizationProjectControllerTests extends BaseTest { } @Test @Order(1) + @Sql(scripts = {"/dml/init_org_project.sql"}, + config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED), + executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) /** * 测试添加项目成功的情况 */ diff --git a/backend/services/system-setting/src/test/resources/dml/init_org_project.sql b/backend/services/system-setting/src/test/resources/dml/init_org_project.sql new file mode 100644 index 0000000000..c4d57320c3 --- /dev/null +++ b/backend/services/system-setting/src/test/resources/dml/init_org_project.sql @@ -0,0 +1,13 @@ +# 插入测试数据 +replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, + last_project_id, create_user, update_user) +VALUES ('admin1', 'test1', 'admin1@metersphere.io', MD5('admin1@metersphere.io'), + UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', 'projectId1', 'admin', 'admin'); +replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, + last_project_id, create_user, update_user) +VALUES ('admin1', 'test1', 'admin1@metersphere.io', MD5('admin1@metersphere.io'), + UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', 'projectId1', 'admin', 'admin'); +replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, + last_project_id, create_user, update_user) +VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'), + UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin'); \ No newline at end of file