(t *testing.T)
| 267 | } |
| 268 | |
| 269 | func TestPrefixQueueUpdateString(t *testing.T) { |
| 270 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
| 271 | pq, err := OpenPrefixQueue(file) |
| 272 | if err != nil { |
| 273 | t.Error(err) |
| 274 | } |
| 275 | defer pq.Drop() |
| 276 | |
| 277 | for i := 1; i <= 10; i++ { |
| 278 | if _, err = pq.EnqueueString("prefix", fmt.Sprintf("value for item %d", i)); err != nil { |
| 279 | t.Error(err) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | item, err := pq.PeekByIDString("prefix", 3) |
| 284 | if err != nil { |
| 285 | t.Error(err) |
| 286 | } |
| 287 | |
| 288 | oldCompStr := "value for item 3" |
| 289 | newCompStr := "new value for item 3" |
| 290 | |
| 291 | if item.ToString() != oldCompStr { |
| 292 | t.Errorf("Expected string to be '%s', got '%s'", oldCompStr, item.ToString()) |
| 293 | } |
| 294 | |
| 295 | updatedItem, err := pq.UpdateString("prefix", item.ID, newCompStr) |
| 296 | if err != nil { |
| 297 | t.Error(err) |
| 298 | } |
| 299 | |
| 300 | if updatedItem.ToString() != newCompStr { |
| 301 | t.Errorf("Expected current item value to be '%s', got '%s'", newCompStr, item.ToString()) |
| 302 | } |
| 303 | |
| 304 | newItem, err := pq.PeekByIDString("prefix", 3) |
| 305 | if err != nil { |
| 306 | t.Error(err) |
| 307 | } |
| 308 | |
| 309 | if newItem.ToString() != newCompStr { |
| 310 | t.Errorf("Expected new item value to be '%s', got '%s'", newCompStr, item.ToString()) |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | func TestPrefixQueueUpdateObject(t *testing.T) { |
| 315 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
nothing calls this directly
no test coverage detected