package io.digdag.server.rs;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import utils.CommandStatus;
import utils.TemporaryDigdagServer;

import java.nio.file.Path;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static utils.TestUtils.copyResource;
import static utils.TestUtils.main;

public class ProjectResourceTest
{
    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    private Path projectDir;

    @Before
    public void setUp()
            throws Exception
    {
        String subDir = "project_resource_test";
        folder.newFolder(subDir);
        projectDir = folder.getRoot().toPath().resolve(subDir);
    }

    @Test
    public void uploadProjectLargerThanLimit()
            throws Exception
    {
        TemporaryDigdagServer server = TemporaryDigdagServer.builder()
                .configuration("api.max_archive_total_size_limit = 1")
                .build();
        server.start();

        String expectMessage = "Size of the uploaded archive file exceeds limit";

        copyResource("acceptance/basic.dig", projectDir.resolve("basic.dig"));
        CommandStatus pushStatus = main("push", "--project", projectDir.toString(), "foobar", "-e", server.endpoint());

        assertThat(pushStatus.errUtf8(), containsString(expectMessage));
    }
}
@@ -332,16 +332,56 @@
 String;%0A
+import static org.hamcrest.Matchers.is;%0A
 import s
@@ -416,16 +416,16 @@
 source;%0A
-
 import s
@@ -802,24 +802,499 @@
 ve(subDir);%0A
+        copyResource(%22acceptance/basic.dig%22, projectDir.resolve(%22basic.dig%22));%0A    %7D%0A%0A    @Test%0A    public void uploadProject()%0A            throws Exception%0A    %7B%0A        TemporaryDigdagServer server = TemporaryDigdagServer.builder()%0A                .build();%0A        server.start();%0A%0A        CommandStatus pushStatus = main(%22push%22, %22--project%22, projectDir.toString(), %22foobar%22, %22-e%22, server.endpoint());%0A%0A        assertThat(pushStatus.code(),is(0));%0A        server.close();%0A
     %7D%0A%0A    @
@@ -1660,87 +1660,8 @@
 %22;%0A%0A
-        copyResource(%22acceptance/basic.dig%22, projectDir.resolve(%22basic.dig%22));%0A
     
@@ -1769,32 +1769,32 @@
 r.endpoint());%0A%0A
-
         assertTh
@@ -1846,19 +1846,43 @@
 tMessage));%0A
+        server.close();%0A
     %7D%0A%7D

Add normal test case