package it.com.atlassian.bitbucket.integrity.repository;

import com.atlassian.bitbucket.test.BaseFuncTest;
import com.atlassian.bitbucket.test.RepositoryTestHelper;
import it.com.atlassian.bitbucket.integrity.RestoreIgnoreRule;
import it.com.atlassian.bitbucket.integrity.SetupUtil;
import it.com.atlassian.bitbucket.integrity.annotation.Ahead;
import it.com.atlassian.bitbucket.integrity.annotation.Behind;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import static it.com.atlassian.bitbucket.integrity.IntegrityTestConstants.RepositoryConstants.*;

public class RepositoryIntegritySetup extends BaseFuncTest {

    private static final String repoContent = "git-repositories/" + PROJECT + "/only-readme-md.zip";

    @Rule
    public RestoreIgnoreRule restoreIgnoreRule = new RestoreIgnoreRule();

    @Before
    public void commonConfiguration() {
        SetupUtil.createProject(PROJECT);
        SetupUtil.createRepo(PROJECT, REPO_OK, repoContent);
        SetupUtil.createRepo(PROJECT, REPO_MISSING, repoContent);
        SetupUtil.createRepo(PROJECT, REPO_EXTRA, repoContent);
    }

    @Behind
    @Test
    public void beforeFirstSnapshot() {
        RepositoryTestHelper.deleteRepository(PROJECT, REPO_EXTRA); // delete extra
    }

    @Ahead
    @Test
    public void beforeSecondSnapshot() {
        RepositoryTestHelper.deleteRepository(PROJECT, REPO_MISSING); // delete missing
    }
}
