-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Removed mandatory GitHub token on artifacts downloading (#1761)
Fixes #1695 ## Test Plan > How do we know the code works? Flank should download test artifacts without any exceptions when GitHub token is not set in environment variables. - [X] Unit tested
- Loading branch information
1 parent
238e379
commit af10786
Showing
5 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package flank.scripts.utils | ||
|
||
fun getEnv(key: String): String = | ||
System.getenv(key) ?: throw RuntimeException("Environment variable '$key' not found!") | ||
|
||
fun getEnv(key: String, default: String? = null): String = | ||
System.getenv(key) ?: default ?: throw RuntimeException("Environment variable '$key' not found!") | ||
val isWindows: Boolean = System.getProperty("os.name").startsWith("Windows") |
18 changes: 18 additions & 0 deletions
18
flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/TestArtifactsRepoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package flank.scripts.ops.testartifacts | ||
|
||
import flank.scripts.data.github.getRelease | ||
import flank.scripts.utils.getEnv | ||
import io.mockk.every | ||
import io.mockk.mockkStatic | ||
import org.junit.Test | ||
|
||
class TestArtifactsRepoTest { | ||
|
||
@Test | ||
fun `should not throw when gh token not set`() { | ||
mockkStatic(::getEnv) | ||
every { getEnv(any(), any()) } returns "" | ||
testArtifactsRepo().getRelease("master") | ||
?.body()?.toLong() | ||
} | ||
} |