Skip to content

Commit 41bf37c

Browse files
authored
Merge pull request #170 from FlowCI/feature/162
Feature/162
2 parents e7cf57c + d045072 commit 41bf37c

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

platform-api/src/main/java/com/flow/platform/api/service/node/NodeServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private Boolean checkFlowName(String flowName) {
288288
return false;
289289
}
290290

291-
if (!Pattern.compile("^\\w{4,20}$").matcher(flowName).matches()) {
291+
if (!Pattern.compile("^(?!_)(?!-)[\\w-]{4,20}$").matcher(flowName).matches()) {
292292
return false;
293293
}
294294

platform-api/src/test/java/com/flow/platform/api/test/integration/ManualJobTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public void should_manual_create_job_with_failure_since_unable_to_create_session
5858
Map<String, String> envs = EnvUtil.build(GitEnvs.FLOW_GIT_BRANCH.name(), "master");
5959
jobService.createWithYmlLoad(
6060
flow.getPath(), JobCategory.MANUAL, envs, currentUser.get(), job -> {
61-
latch.countDown();
6261
wrapper.setInstance(job);
62+
latch.countDown();
6363
}
6464
);
6565

platform-api/src/test/java/com/flow/platform/api/test/service/NodeServiceTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,28 @@ public void should_delete_flow() throws Throwable {
276276
// then: should return null if root node is not existed
277277
Assert.assertNull(ymlService.get(root));
278278
}
279+
280+
@Test
281+
public void should_create_flow_success() {
282+
Assert.assertNotNull(nodeService.createEmptyFlow("flow-test"));
283+
Assert.assertNotNull(nodeService.createEmptyFlow("flow_test"));
284+
Assert.assertNotNull(nodeService.createEmptyFlow("flow_12est"));
285+
Assert.assertNotNull(nodeService.createEmptyFlow("flow12est"));
286+
Assert.assertNotNull(nodeService.createEmptyFlow("flow"));
287+
}
288+
289+
@Test(expected = IllegalParameterException.class)
290+
public void should_create_flow_error() {
291+
// not start with _
292+
nodeService.createEmptyFlow("_flow-test");
293+
294+
// not start with -
295+
nodeService.createEmptyFlow("-flow-test");
296+
297+
// not include .
298+
nodeService.createEmptyFlow("flow.test");
299+
300+
// not include 3 keys
301+
nodeService.createEmptyFlow("flw");
302+
}
279303
}

platform-util-zk/src/test/java/com/flow/platform/util/zk/test/ZkClientTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public void should_create_node_atom() throws Throwable {
8989

9090
zkClient.create(root, null);
9191
String agentNodePath = ZKPaths.makePath(root, "flow-atom");
92+
9293
zkClient.delete(agentNodePath, false);
9394

9495
for (int i = 0; i < 5; i++) {

0 commit comments

Comments
 (0)