mirror of
https://github.com/iv-org/invidious.git
synced 2025-11-04 14:18:30 -06:00
Commit the whole ./lib/ folder which stores the Crystal dependencies. This has a few benefits: - Allows to build the project without a connection to the Internet to retrieve dependencies. - Makes the project resistant against dependency re-tags which might include malicious code.
34 lines
733 B
Crystal
34 lines
733 B
Crystal
require "spec"
|
|
require "../src/sqlite3"
|
|
|
|
include SQLite3
|
|
|
|
DB_FILENAME = "./test.db"
|
|
|
|
def with_db(&block : DB::Database ->)
|
|
File.delete(DB_FILENAME) rescue nil
|
|
DB.open "sqlite3:#{DB_FILENAME}", &block
|
|
ensure
|
|
File.delete(DB_FILENAME)
|
|
end
|
|
|
|
def with_cnn(&block : DB::Connection ->)
|
|
File.delete(DB_FILENAME) rescue nil
|
|
DB.connect "sqlite3:#{DB_FILENAME}", &block
|
|
ensure
|
|
File.delete(DB_FILENAME)
|
|
end
|
|
|
|
def with_db(config, &block : DB::Database ->)
|
|
uri = "sqlite3:#{config}"
|
|
filename = SQLite3::Connection.filename(URI.parse(uri))
|
|
File.delete(filename) rescue nil
|
|
DB.open uri, &block
|
|
ensure
|
|
File.delete(filename) if filename
|
|
end
|
|
|
|
def with_mem_db(&block : DB::Database ->)
|
|
DB.open "sqlite3://%3Amemory%3A", &block
|
|
end
|