Skip to content

Commit

Permalink
doc: add some unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Feb 5, 2023
1 parent f66c38a commit 29d14d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: login docker hub
run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login -u zhouyixun --password-stdin
- name: Validate and Compile with Maven
run: mvn package
run: mvn package -Dmaven.test.skip=true
- name: deploy controller
run: docker build -t sonicorg/sonic-server-controller:${{ steps.previoustag.outputs.tag }} -f sonic-server-controller/src/main/docker/Dockerfile .
- name: push controller
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.cloud.sonic.controller.service.impl;

import com.alibaba.fastjson.JSONObject;
import org.cloud.sonic.controller.ControllerApplication;
import org.cloud.sonic.controller.models.domain.Jobs;
import org.cloud.sonic.controller.models.interfaces.JobStatus;
import org.cloud.sonic.controller.services.JobsService;
import org.junit.Assert;
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.junit4.SpringRunner;

import java.util.List;

@SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class JobServiceImplTest {
@Autowired
private JobsService jobsService;

@Test
public void testFindSysJob() {
List<JSONObject> list = jobsService.findSysJobs();
Assert.assertEquals(4, list.size());
}

@Test
public void testSaveJob() {
Jobs jobs = new Jobs();
jobs.setName("Hello");
jobs.setSuiteId(1);
jobs.setProjectId(1);
jobs.setCronExpression("0 0 0 * * ?");
jobsService.saveJobs(jobs);
Assert.assertEquals("testJob", jobs.getType());
Assert.assertEquals(JobStatus.ENABLE, (int) jobs.getStatus());
Assert.assertEquals(jobs, jobsService.findById(jobs.getId()));
jobsService.delete(jobs.getId());
}
}

0 comments on commit 29d14d5

Please sign in to comment.