reghao 1 rok pred
rodič
commit
13cd17c7ba

+ 34 - 0
web/src/test/java/cn/reghao/devops/web/admin/MessageTest.java

@@ -0,0 +1,34 @@
+package cn.reghao.devops.web.admin;
+
+import cn.reghao.devops.web.WebApplication;
+import cn.reghao.devops.web.admin.sys.db.repository.EmailAccountRepository;
+import cn.reghao.devops.web.admin.sys.db.repository.NotifyReceiverRepository;
+import cn.reghao.devops.web.admin.sys.service.NotifyService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author reghao
+ * @date 2024-08-03 10:27:07
+ */
+@Slf4j
+@ActiveProfiles("dev")
+@SpringBootTest(classes = WebApplication.class)
+@RunWith(SpringRunner.class)
+public class MessageTest {
+    @Autowired
+    NotifyReceiverRepository notifyReceiverRepository;
+    @Autowired
+    EmailAccountRepository emailAccountRepository;
+    @Autowired
+    NotifyService notifyService;
+
+    @Test
+    public void notifyTest() throws InterruptedException {
+    }
+}

+ 42 - 18
web/src/test/java/cn/reghao/devops/web/devops/AppConfigTest.java

@@ -5,13 +5,13 @@ import cn.reghao.devops.web.mgr.app.db.repository.AppBuildingRepository;
 import cn.reghao.devops.web.mgr.app.db.repository.AppDeployingRepository;
 import cn.reghao.devops.web.mgr.app.db.repository.config.AppConfigRepository;
 import cn.reghao.devops.web.mgr.app.db.repository.config.AppDeployConfigRepository;
+import cn.reghao.devops.web.mgr.app.db.repository.log.BuildLogRepository;
 import cn.reghao.devops.web.mgr.app.model.po.AppDeploying;
 import cn.reghao.devops.web.mgr.app.model.po.AppDeployingNode;
 import cn.reghao.devops.web.mgr.app.model.po.config.AppConfig;
 import cn.reghao.devops.web.mgr.app.model.po.config.AppDeployConfig;
-import cn.reghao.devops.web.admin.sys.service.NotifyService;
-import cn.reghao.devops.web.admin.sys.db.repository.EmailAccountRepository;
-import cn.reghao.devops.web.admin.sys.db.repository.NotifyReceiverRepository;
+import cn.reghao.devops.web.mgr.app.model.po.log.BuildConsumed;
+import cn.reghao.devops.web.mgr.app.model.po.log.BuildLog;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -31,21 +31,6 @@ import java.util.List;
 @SpringBootTest(classes = WebApplication.class)
 @RunWith(SpringRunner.class)
 public class AppConfigTest {
-    @Autowired
-    NotifyReceiverRepository notifyReceiverRepository;
-    @Autowired
-    EmailAccountRepository emailAccountRepository;
-
-    @Test
-    public void initNotifyTest() throws InterruptedException {
-    }
-
-    @Autowired
-    NotifyService notifyService;
-    @Test
-    public void notifyTest() throws InterruptedException {
-    }
-
     @Autowired
     AppBuildingRepository buildingRepository;
     @Autowired
@@ -88,4 +73,43 @@ public class AppConfigTest {
             }
         });
     }
+
+    @Autowired
+    BuildLogRepository buildLogRepository;
+    @Test
+    public void buildLogTest() {
+        List<BuildLog> buildLogs = buildLogRepository.findAll();
+        buildLogs.forEach(buildLog -> {
+            BuildConsumed buildConsumed = buildLog.getBuildConsumed();
+            if (buildConsumed == null) {
+                return;
+            }
+
+            Long l1 = buildConsumed.getPullConsumed();
+            Long l2 = buildConsumed.getCompileConsumed();
+            Long l3 = buildConsumed.getPackConsumed();
+            Long l4 = buildConsumed.getPushConsumed();
+
+            Long total = 0L;
+            if (l1 != null) {
+                total += l1;
+            }
+
+            if (l2 != null) {
+                total += l2;
+            }
+
+            if (l3 != null) {
+                total += l3;
+            }
+
+            if (l4 != null) {
+                total += l3;
+            }
+
+            buildConsumed.setTotal(total/1000);
+        });
+
+        buildLogRepository.saveAll(buildLogs);
+    }
 }