<commit_before>package sdkman.specs

import com.github.tomakehurst.wiremock.WireMockServer
import sdkman.env.CleanBashEnvBuilder
import sdkman.support.BashEnvSpecification
import sdkman.support.WireMockServerProvider

import java.nio.file.Files
import java.nio.file.Paths

import static sdkman.stubs.WebServiceStub.primeEndpointWithBinary
import static sdkman.stubs.WebServiceStub.primeEndpointWithString
import static sdkman.support.FilesystemUtils.prepareBaseDir

class InstallSpec extends BashEnvSpecification {

    final service = "http://localhost:8080"
    WireMockServer wireMockServer

    File sdkmanBaseDirectory

    void setup() {
        sdkmanBaseDirectory = prepareBaseDir()
        bash = CleanBashEnvBuilder.create(sdkmanBaseDirectory).build()
        bash.start()
        wireMockServer = WireMockServerProvider.wireMockServer()
        primeInstallScriptEndpoint()
        primeDownloadSdkmanEndpoint()
    }

    void "should install init script at bin dir"() {
        given:
        def sdkmanBinFolder = new File(sdkmanBaseDirectory, ".sdkman/bin")
        def sdkmanInitScript = new File(sdkmanBinFolder, "sdkman-init.sh")<commit_msg>Add cleanup hook to InstallSpec.<commit_after>package sdkman.specs

import com.github.tomakehurst.wiremock.WireMockServer
import sdkman.env.CleanBashEnvBuilder
import sdkman.support.BashEnvSpecification
import sdkman.support.WireMockServerProvider

import java.nio.file.Files
import java.nio.file.Paths

import static sdkman.stubs.WebServiceStub.primeEndpointWithBinary
import static sdkman.stubs.WebServiceStub.primeEndpointWithString
import static sdkman.support.FilesystemUtils.prepareBaseDir

class InstallSpec extends BashEnvSpecification {

    final service = "http://localhost:8080"
    WireMockServer wireMockServer

    File sdkmanBaseDirectory

    void setup() {
        sdkmanBaseDirectory = prepareBaseDir()
        bash = CleanBashEnvBuilder.create(sdkmanBaseDirectory).build()
        bash.start()
        wireMockServer = WireMockServerProvider.wireMockServer()
        primeInstallScriptEndpoint()
        primeDownloadSdkmanEndpoint()
    }

    def cleanup() {
        assert sdkmanBaseDirectory.deleteDir()
    }

    void "should install init script at bin dir"() {
        given:
        def sdkmanBinFolder = new File(sdkmanBaseDirectory, ".sdkman/bin")
        def sdkmanInitScript = new File(sdkmanBinFolder, "sdkman-init.sh")
{'fraction_non_alphanumeric': 0.07299875570302779, 'fraction_numerical': 0.0033181252592285357, 'mean_word_length': 4.2894736842105265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5892951', 'n_tokens_mistral': 702, 'n_tokens_neox': 676, 'n_words': 135}