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

com.netflix.spinnaker.keel.services.versionLinksUtils.kt Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
package com.netflix.spinnaker.keel.services

import com.github.benmanes.caffeine.cache.AsyncLoadingCache
import com.netflix.spinnaker.keel.api.ScmInfo
import com.netflix.spinnaker.keel.artifacts.ArtifactVersionLinks
import com.netflix.spinnaker.keel.caffeine.CacheFactory
import io.mockk.coEvery
import io.mockk.every
import io.mockk.mockk
import java.util.concurrent.CompletableFuture
import java.util.function.Function

val scmData = mapOf("stash" to "https://stash")

fun mockScmInfo(): ScmInfo {
  return mockk() {
    coEvery> {
      getScmInfo()
    } answers {
      scmData
    }
  }
}

fun mockCacheFactory(): CacheFactory {
  val asyncLoadingCache: AsyncLoadingCache> = mockk {
    val cache = this
    every {
      get(any(), any() as Function>)
    } returns CompletableFuture.supplyAsync { scmData }
    coEvery {
      cache[any()]
    } returns CompletableFuture.supplyAsync { scmData }
  }

  return mockk() {
    every>> {
      asyncLoadingCache>(any(), any(), any(), any(), any())
    } returns asyncLoadingCache
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy