|
@@ -25,4 +25,31 @@ func TestAutoType(t *testing.T) {
|
|
|
if result.ID != "123" {
|
|
|
t.Fatal("result not correct")
|
|
|
}
|
|
|
+
|
|
|
+ if err := AutoDelete[TestAutoTypeStruct]("test"); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestAutoTypeWithGetter(t *testing.T) {
|
|
|
+ if err := InitRedisClient("127.0.0.1:6379", "difyai123456"); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ defer Close()
|
|
|
+
|
|
|
+ result, err := AutoGetWithGetter("test1", func() (*TestAutoTypeStruct, error) {
|
|
|
+ return &TestAutoTypeStruct{
|
|
|
+ ID: "123",
|
|
|
+ }, nil
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ if err := AutoDelete[TestAutoTypeStruct]("test1"); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if result.ID != "123" {
|
|
|
+ t.Fatal("result not correct")
|
|
|
+ }
|
|
|
}
|