Disable some tests on CI
This commit is contained in:
parent
53151d868a
commit
690227adda
1 changed files with 2 additions and 23 deletions
|
@ -98,100 +98,79 @@ class BitlinksTests {
|
||||||
inner class ConstructorTests {
|
inner class ConstructorTests {
|
||||||
@Test
|
@Test
|
||||||
fun `Constructor with access token string should set the token correctly`() {
|
fun `Constructor with access token string should set the token correctly`() {
|
||||||
// Arrange
|
|
||||||
val expectedToken = "my-secret-token"
|
val expectedToken = "my-secret-token"
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly(expectedToken)
|
val bitly = Bitly(expectedToken)
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Constructor with Path should not change token if file does not exist`() {
|
fun `Constructor with Path should not change token if file does not exist`() {
|
||||||
// Arrange
|
|
||||||
val nonExistentPath = File("non/existent/path/file.properties").toPath()
|
val nonExistentPath = File("non/existent/path/file.properties").toPath()
|
||||||
val bitlyWithDefaultToken = Bitly()
|
val bitlyWithDefaultToken = Bitly()
|
||||||
val initialToken = bitlyWithDefaultToken.accessToken
|
val initialToken = bitlyWithDefaultToken.accessToken
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly(nonExistentPath)
|
val bitly = Bitly(nonExistentPath)
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEqualTo(initialToken)
|
assertThat(bitly.accessToken).isEqualTo(initialToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Constructor with Properties and custom key should set token correctly`() {
|
fun `Constructor with Properties and custom key should set token correctly`() {
|
||||||
// Arrange
|
|
||||||
val customKey = "MY_CUSTOM_BITLY_KEY"
|
val customKey = "MY_CUSTOM_BITLY_KEY"
|
||||||
val expectedToken = "token-from-custom-key"
|
val expectedToken = "token-from-custom-key"
|
||||||
val properties = Properties().apply {
|
val properties = Properties().apply {
|
||||||
setProperty(customKey, expectedToken)
|
setProperty(customKey, expectedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly(properties, customKey)
|
val bitly = Bitly(properties, customKey)
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Constructor with Properties should keep default token if key not found`() {
|
fun `Constructor with Properties should keep default token if key not found`() {
|
||||||
// Arrange
|
|
||||||
val properties = Properties() // Empty properties
|
val properties = Properties() // Empty properties
|
||||||
val bitlyWithDefaultToken = Bitly() // Has "" as token by default
|
val bitlyWithDefaultToken = Bitly() // Has "" as token by default
|
||||||
val initialToken = bitlyWithDefaultToken.accessToken
|
val initialToken = bitlyWithDefaultToken.accessToken
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly(properties, "non-existent-key")
|
val bitly = Bitly(properties, "non-existent-key")
|
||||||
|
|
||||||
// Assert
|
|
||||||
// The token should remain the default empty string
|
// The token should remain the default empty string
|
||||||
assertThat(bitly.accessToken).isEqualTo(initialToken)
|
assertThat(bitly.accessToken).isEqualTo(initialToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Constructor with Properties should set token using default key`() {
|
fun `Constructor with Properties should set token using default key`() {
|
||||||
// Arrange
|
|
||||||
val expectedToken = "token-from-props"
|
val expectedToken = "token-from-props"
|
||||||
val properties = Properties().apply {
|
val properties = Properties().apply {
|
||||||
setProperty(Constants.ENV_ACCESS_TOKEN, expectedToken)
|
setProperty(Constants.ENV_ACCESS_TOKEN, expectedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly(properties)
|
val bitly = Bitly(properties)
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableOnCi
|
||||||
fun `Default constructor should default to empty string if no token is provided`() {
|
fun `Default constructor should default to empty string if no token is provided`() {
|
||||||
// Arrange: Ensure no env var or system property is set
|
|
||||||
System.clearProperty(Constants.ENV_ACCESS_TOKEN)
|
System.clearProperty(Constants.ENV_ACCESS_TOKEN)
|
||||||
// Note: Testing environment variables directly is often avoided in unit tests.
|
|
||||||
// This test verifies the fallback mechanism.
|
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly()
|
val bitly = Bitly()
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEmpty()
|
assertThat(bitly.accessToken).isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableOnCi
|
||||||
fun `Default constructor should use system property if env var is not set`() {
|
fun `Default constructor should use system property if env var is not set`() {
|
||||||
// Arrange
|
|
||||||
val expectedToken = "token-from-property"
|
val expectedToken = "token-from-property"
|
||||||
System.setProperty(Constants.ENV_ACCESS_TOKEN, expectedToken)
|
System.setProperty(Constants.ENV_ACCESS_TOKEN, expectedToken)
|
||||||
|
|
||||||
// Act
|
|
||||||
val bitly = Bitly()
|
val bitly = Bitly()
|
||||||
|
|
||||||
// Assert
|
|
||||||
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
assertThat(bitly.accessToken).isEqualTo(expectedToken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue