All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.cache.internal.UsedGradleVersionsFromGradleUserHomeCachesTest.groovy Maven / Gradle / Ivy

There is a newer version: 8.6
Show newest version
/*
 * Copyright 2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.cache.internal

import org.gradle.test.fixtures.file.CleanupTestDirectory
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
import org.gradle.util.GradleVersion
import org.junit.Rule
import spock.lang.Specification
import spock.lang.Subject

@CleanupTestDirectory
class UsedGradleVersionsFromGradleUserHomeCachesTest extends Specification {

    @Rule TestNameTestDirectoryProvider temporaryFolder = new TestNameTestDirectoryProvider()

    def userHomeDir = temporaryFolder.createDir("user-home")
    def cacheBaseDir = userHomeDir.createDir(DefaultCacheScopeMapping.GLOBAL_CACHE_DIR_NAME)
    def cacheScopeMapping = new DefaultCacheScopeMapping(userHomeDir, null, GradleVersion.current())

    @Subject UsedGradleVersions versions = new UsedGradleVersionsFromGradleUserHomeCaches(cacheScopeMapping)

    def "returns Gradle versions from version-specific cache directories"() {
        given:
        cacheBaseDir.createDir("_foo")
        cacheBaseDir.createDir("1.2.3-rc-1")
        cacheBaseDir.createDir("0.9-20101220110000+1100")
        cacheBaseDir.createDir("2.3.4")
        cacheBaseDir.createDir("99_BAR")
        cacheBaseDir.createDir("ZZZZ")

        when:
        def versions = versions.getUsedGradleVersions()

        then:
        versions as List == [
            GradleVersion.version("0.9-20101220110000+1100"),
            GradleVersion.version("1.2.3-rc-1"),
            GradleVersion.version("2.3.4")
        ]
    }}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy