libdoltlite-sys 0.38.23

Native bindings to the DoltLite SQLite-compatible library
Documentation
#
# 13-May-2022
#
#-------------------------------------------------------------------------
#

source [file join [file dirname [info script]] test_common.tcl]
set testprefix dmn_auth2

if {$C(use_sas)==0} {
  finish_test
  return
}

bcv_create_container cont1
bcv_upload_new_db cont1 t1.db {
  CREATE TABLE x1(x, y);
  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<4000
  )
  INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;
}

start_new_daemon 0 

set ::nAuthCallback 0
proc my_auth_callback {zStorage zAccount zContainer} {
  incr ::nAuthCallback
  set sas [make_sas $zContainer 2]
  return $sas
}

set cmd [bcvfs_create testdir.0 bcvfs]
$cmd auth_callback my_auth_callback
bcvfs_attach $cmd cont1

sqlite3 db /cont1/t1.db -vfs bcvfs
sqlite3_bcvfs_register_vtab db

do_test 1.0 {
  $cmd prefetch_new pf cont1 t1.db
  pf run 1 1000
} {0}

wait_ms 3000

do_test 1.1 {
  pf run 1 1000
} {0}

do_execsql_test 1.2 {
  SELECT * FROM bcv_database
} {
  cont1 t1.db 7 2 0 0 {} 1 1 1
}

do_test 1.3 {
  while {[pf run 2 1000]==0} {}
  pf destroy
} {}

do_execsql_test 1.4 {
  SELECT * FROM bcv_database
} {
  cont1 t1.db 7 7 0 0 {} 1 0 1
}

db close
$cmd destroy
wait_daemon 0


finish_test