-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
testing github actions #8 comment out the redis connection tests that…
… don't use testcontainers
Showing
2 changed files
with
81 additions
and
81 deletions.
There are no files selected for viewing
68 changes: 34 additions & 34 deletions
68
src/test/java/io/github/ardoco/rest/api/RedisConnectionTest.java
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,34 +1,34 @@ | ||
package io.github.ardoco.rest.api; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.data.redis.core.StringRedisTemplate; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
@SpringBootTest | ||
public class RedisConnectionTest { | ||
|
||
@Autowired | ||
private StringRedisTemplate redisTemplate; | ||
|
||
@Test | ||
public void testRedisConnection() { | ||
String key = "test:connection"; | ||
String value = "connected"; | ||
|
||
// Set a value in Redis | ||
redisTemplate.opsForValue().set(key, value); | ||
|
||
// Get the value from Redis | ||
String retrievedValue = redisTemplate.opsForValue().get(key); | ||
|
||
// Assert that the retrieved value matches the set value | ||
assertThat(retrievedValue).isEqualTo(value); | ||
|
||
// Clean up | ||
redisTemplate.delete(key); | ||
} | ||
} | ||
//package io.github.ardoco.rest.api; | ||
// | ||
//import org.junit.jupiter.api.Test; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; | ||
//import org.springframework.boot.test.context.SpringBootTest; | ||
//import org.springframework.data.redis.core.StringRedisTemplate; | ||
// | ||
//import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
// | ||
//@SpringBootTest | ||
//public class RedisConnectionTest { | ||
// | ||
// @Autowired | ||
// private StringRedisTemplate redisTemplate; | ||
// | ||
// @Test | ||
// public void testRedisConnection() { | ||
// String key = "test:connection"; | ||
// String value = "connected"; | ||
// | ||
// // Set a value in Redis | ||
// redisTemplate.opsForValue().set(key, value); | ||
// | ||
// // Get the value from Redis | ||
// String retrievedValue = redisTemplate.opsForValue().get(key); | ||
// | ||
// // Assert that the retrieved value matches the set value | ||
// assertThat(retrievedValue).isEqualTo(value); | ||
// | ||
// // Clean up | ||
// redisTemplate.delete(key); | ||
// } | ||
//} |
94 changes: 47 additions & 47 deletions
94
src/test/java/io/github/ardoco/rest/api/RedisRealConnectionTest.java
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,47 +1,47 @@ | ||
package io.github.ardoco.rest.api; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.data.redis.core.StringRedisTemplate; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") // Ensure test profile is used to avoid side effects | ||
public class RedisRealConnectionTest { | ||
|
||
@Autowired | ||
private StringRedisTemplate redisTemplate; | ||
|
||
/*@Test | ||
public void testRedisConnection() { | ||
// Attempt to connect and perform a basic operation | ||
String key = "test:connection"; | ||
String value = "connected"; | ||
// Set a value in Redis | ||
redisTemplate.opsForValue().set(key, value); | ||
// Get the value from Redis | ||
String retrievedValue = redisTemplate.opsForValue().get(key); | ||
// Assert that the retrieved value matches the set value | ||
assertThat(retrievedValue).isEqualTo(value); | ||
// Clean up | ||
redisTemplate.delete(key); | ||
}*/ | ||
|
||
// @Test | ||
// public void testRedisConnectionFailure() { | ||
// // Use invalid configuration or catch connection failures to test the error handling | ||
// // For example, check if wrong credentials throw a RedisConnectionFailureException | ||
// | ||
// assertThatThrownBy(() -> { | ||
// redisTemplate.opsForValue().get("invalid_key"); | ||
// }).hasRootCauseInstanceOf(org.springframework.data.redis.RedisConnectionFailureException.class); | ||
// } | ||
} | ||
//package io.github.ardoco.rest.api; | ||
// | ||
//import org.junit.jupiter.api.Test; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.test.context.SpringBootTest; | ||
//import org.springframework.data.redis.core.StringRedisTemplate; | ||
//import org.springframework.test.context.ActiveProfiles; | ||
// | ||
//import static org.assertj.core.api.Assertions.assertThat; | ||
//import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
// | ||
//@SpringBootTest | ||
//@ActiveProfiles("test") // Ensure test profile is used to avoid side effects | ||
//public class RedisRealConnectionTest { | ||
// | ||
// @Autowired | ||
// private StringRedisTemplate redisTemplate; | ||
// | ||
// /*@Test | ||
// public void testRedisConnection() { | ||
// // Attempt to connect and perform a basic operation | ||
// String key = "test:connection"; | ||
// String value = "connected"; | ||
// | ||
// // Set a value in Redis | ||
// redisTemplate.opsForValue().set(key, value); | ||
// | ||
// // Get the value from Redis | ||
// String retrievedValue = redisTemplate.opsForValue().get(key); | ||
// | ||
// // Assert that the retrieved value matches the set value | ||
// assertThat(retrievedValue).isEqualTo(value); | ||
// | ||
// // Clean up | ||
// redisTemplate.delete(key); | ||
// }*/ | ||
// | ||
//// @Test | ||
//// public void testRedisConnectionFailure() { | ||
//// // Use invalid configuration or catch connection failures to test the error handling | ||
//// // For example, check if wrong credentials throw a RedisConnectionFailureException | ||
//// | ||
//// assertThatThrownBy(() -> { | ||
//// redisTemplate.opsForValue().get("invalid_key"); | ||
//// }).hasRootCauseInstanceOf(org.springframework.data.redis.RedisConnectionFailureException.class); | ||
//// } | ||
//} |