package com.guwan;

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.RedisTemplate;

import static org.junit.jupiter.api.Assertions.assertEquals;


@SpringBootTest
public class RedisTest {
    @Autowired
    private RedisTemplate redisTemplate;



    @Test
    public void testSaveUser() {
        String key = "user:1";
        String value = "John Doe";

        redisTemplate.opsForValue().set(key, value); // 保存数据

        // 验证数据是否保存成功
        String retrievedValue = (String) redisTemplate.opsForValue().get(key);
        assertEquals(value, retrievedValue, "Retrieved value should match the saved value");
    }
}
