| 106 | } |
| 107 | |
| 108 | func TestStringGet(t *testing.T) { |
| 109 | setValue(t, TestExistKey, value) |
| 110 | tests := []struct { |
| 111 | name string |
| 112 | key []byte |
| 113 | value []byte |
| 114 | want []byte |
| 115 | }{ |
| 116 | { |
| 117 | name: "TestString_GetExitKey", |
| 118 | key: TestExistKey, |
| 119 | value: value, |
| 120 | want: value, |
| 121 | }, |
| 122 | { |
| 123 | name: "TestString_GetNoExitKey", |
| 124 | key: TestNoExistKey, |
| 125 | value: nil, |
| 126 | want: nil, |
| 127 | }, |
| 128 | } |
| 129 | for _, tt := range tests { |
| 130 | t.Run(tt.name, func(t *testing.T) { |
| 131 | callFunc := func(txn *Transaction) { |
| 132 | s, err := GetString(txn, tt.key) |
| 133 | assert.NoError(t, err) |
| 134 | got, err := s.Get() |
| 135 | assert.Equal(t, got, tt.want) |
| 136 | } |
| 137 | MockTest(t, callFunc) |
| 138 | }) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | func TestStringSet(t *testing.T) { |
| 143 | var exp = []int64{int64(2 * time.Second)} |