rburename.test 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # 2022 November 07
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. #
  12. #
  13. source [file join [file dirname [info script]] rbu_common.tcl]
  14. if_no_rbu_support { finish_test ; return }
  15. set ::testprefix rburename
  16. do_execsql_test 1.0 {
  17. CREATE TABLE t1(a, b);
  18. INSERT INTO t1 VALUES(1, 2);
  19. INSERT INTO t1 VALUES(3, 4);
  20. INSERT INTO t1 VALUES(5, 6);
  21. }
  22. forcedelete test.db-vacuum
  23. proc my_rename {old new} {
  24. lappend ::my_rename_calls [list [file tail $old] [file tail $new]]
  25. file rename $old $new
  26. }
  27. do_test 1.1 {
  28. sqlite3rbu_vacuum rbu test.db
  29. rbu rename_handler my_rename
  30. while {[rbu step]=="SQLITE_OK"} {}
  31. rbu close
  32. } SQLITE_DONE
  33. do_test 1.2 {
  34. set ::my_rename_calls
  35. } {{test.db-oal test.db-wal}}
  36. proc my_rename {old new} {
  37. error "something went wrong"
  38. }
  39. do_test 1.3 {
  40. sqlite3rbu_vacuum rbu test.db
  41. rbu rename_handler my_rename
  42. while {[rbu step]=="SQLITE_OK"} {}
  43. list [catch { rbu close } msg] $msg
  44. } {1 SQLITE_IOERR}
  45. finish_test