package com.atlassian.bitbucket.installer.validation;


import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;

import java.io.File;

public class PathSpacesValidationStrategyTest {

    @Rule
    public final ExpectedException expectedException = ExpectedException.none();
    @Rule
    public final TemporaryFolder testFolder = new TemporaryFolder();

    private PathSpacesValidationStrategy validationStrategy;

    @Before
    public void setup() {
        validationStrategy = new PathSpacesValidationStrategy();
    }

    @Test
    public void testSpacesInDirectoryPath() throws Exception {
        expectedException.expect(HardValidationException.class);
        expectedException.expectMessage(HardValidationException.ERROR_DIRECTORY_SPACES);
        File directory = testFolder.newFolder("garbage with spaces");

        validationStrategy.validate(directory);
    }
}
