{"id":18981400,"url":"https://github.com/awncorp/test-db","last_synced_at":"2026-05-08T16:49:20.105Z","repository":{"id":55032662,"uuid":"253044854","full_name":"awncorp/test-db","owner":"awncorp","description":"Temporary Databases for Testing","archived":false,"fork":false,"pushed_at":"2021-01-14T07:11:31.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-01T11:27:31.339Z","etag":null,"topics":["automation","database","perl","perl5","testing"],"latest_commit_sha":null,"homepage":"https://metacpan.org/release/Test-DB","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awncorp.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-04T16:24:28.000Z","updated_at":"2022-07-24T21:01:47.000Z","dependencies_parsed_at":"2022-08-14T09:40:34.842Z","dependency_job_id":null,"html_url":"https://github.com/awncorp/test-db","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Ftest-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Ftest-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Ftest-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awncorp%2Ftest-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awncorp","download_url":"https://codeload.github.com/awncorp/test-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239985746,"owners_count":19729519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","database","perl","perl5","testing"],"created_at":"2024-11-08T16:09:44.398Z","updated_at":"2025-11-11T16:02:27.014Z","avatar_url":"https://github.com/awncorp.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n\n    Test::DB - Temporary Testing Databases\n\nABSTRACT\n\n    Temporary Databases for Testing\n\nSYNOPSIS\n\n      use Test::DB;\n    \n      my $tdb = Test::DB-\u003enew;\n    \n      # my $tdbo = $tdb-\u003ecreate(database =\u003e 'sqlite');\n    \n      # my $dbh = $tdbo-\u003edbh;\n\nDESCRIPTION\n\n    This package provides a framework for setting up and tearing down\n    temporary databases for testing purposes. This framework requires a\n    user (optionally with password) which has the ability to create new\n    databases and works by creating test-specific databases owned by the\n    user specified. Note: Test databases are not automatically destroyed\n    and should be cleaned up manually by call the destroy method on the\n    database-specific test database object.\n\n process\n\n    on create, clone\n\n    #1\n\n      Establish a connection to the DB using some \"initial\" database.\n\n        my $tdbo = $tdb-\u003epostgres(initial =\u003e 'template0');\n\n    #2\n\n      Using the established connection, create the test/temporary database.\n\n        $tdbo-\u003ecreate;\n\n    #3\n\n      Establish a connection to the newly created test/temporary database.\n\n        $tdbo-\u003ecreate-\u003edbh;\n\n    #4\n\n      Make the test database object immutable.\n\n        $tdbo-\u003ecreate-\u003edatabase('example'); # error\n\n    on destroy\n\n    #1\n\n      Establish a connection to the DB using the \"initial\" database.\n\n        # using the created test/temporary database object\n\n    #2\n\n      Using the established connection, drop the test/temporary database.\n\n        $tdbo-\u003edestroy;\n\n usages\n\n    using DBI\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $dbh = $tdb-\u003esqlite(%options)-\u003edbh;\n\n    using DBIx::Class\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $tdbo = $tdb-\u003epostgres(%options)-\u003ecreate;\n        my $schema = DBIx::Class::Schema-\u003econnect(\n          dsn =\u003e $tdbo-\u003edsn,\n          username =\u003e $tdbo-\u003eusername,\n          password =\u003e $tdbo-\u003epassword,\n        );\n\n    using Mojo::mysql\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $tdbo = $tdb-\u003emysql(%options)-\u003ecreate;\n        my $mysql = Mojo::mysql-\u003enew($tdbo-\u003euri);\n\n    using Mojo::Pg\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $tdbo = $tdb-\u003epostgres(%options)-\u003ecreate;\n        my $postgres = Mojo::Pg-\u003enew($tdbo-\u003euri);\n\n    using Mojo::Pg (with cloning)\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $tdbo = $tdb-\u003epostgres(%options)-\u003eclone('template0');\n        my $postgres = Mojo::Pg-\u003enew($tdbo-\u003euri);\n\n    using Mojo::SQLite\n\n    #1\n\n        my $tdb = Test::DB-\u003enew;\n        my $tdbo = $tdb-\u003esqlite(%options)-\u003ecreate;\n        my $sqlite = Mojo::SQLite-\u003enew($tdbo-\u003euri);\n\nLIBRARIES\n\n    This package uses type constraints from:\n\n    Types::Standard\n\nMETHODS\n\n    This package implements the following methods:\n\n clone\n\n      clone(Str :$database, Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The clone method generates a database based on the type and database\n    template specified and returns a Test::DB::Object with an active\n    connection, dbh and dsn. If the database specified doesn't have a\n    corresponding database driver this method will returned the undefined\n    value. The type of database can be omitted if the TESTDB_DATABASE\n    environment variable is set, if not the type of database must be either\n    sqlite, mysql, mssql or postgres. Any options provided are passed along\n    to the test database object class constructor.\n\n    clone example #1\n\n        # given: synopsis\n      \n        $ENV{TESTDB_DATABASE} = 'postgres';\n      \n        $tdb-\u003eclone(template =\u003e 'template0');\n\n    clone example #2\n\n        # given: synopsis\n      \n        $ENV{TESTDB_DATABASE} = 'postgres';\n        $ENV{TESTDB_TEMPLATE} = 'template0';\n      \n        $tdb-\u003eclone;\n\n    clone example #3\n\n        # given: synopsis\n      \n        $ENV{TESTDB_TEMPLATE} = 'template0';\n      \n        $tdb-\u003eclone(database =\u003e 'postgres');\n\n create\n\n      create(Str :$database, Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The create method generates a database based on the type specified and\n    returns a Test::DB::Object with an active connection, dbh and dsn. If\n    the database specified doesn't have a corresponding database driver\n    this method will returned the undefined value. The type of database can\n    be omitted if the TESTDB_DATABASE environment variable is set, if not\n    the type of database must be either sqlite, mysql, mssql or postgres.\n    Any options provided are passed along to the test database object class\n    constructor.\n\n    create example #1\n\n        # given: synopsis\n      \n        $tdb-\u003ecreate;\n\n    create example #2\n\n        # given: synopsis\n      \n        $ENV{TESTDB_DATABASE} = 'sqlite';\n      \n        $tdb-\u003ecreate;\n\n    create example #3\n\n        # given: synopsis\n      \n        $tdb-\u003ecreate(database =\u003e 'sqlite');\n\n mssql\n\n      mssql(Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The mssql method builds and returns a Test::DB::Mssql object.\n\n    mssql example #1\n\n        # given: synopsis\n      \n        $tdb-\u003emssql;\n\n mysql\n\n      mysql(Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The mysql method builds and returns a Test::DB::Mysql object.\n\n    mysql example #1\n\n        # given: synopsis\n      \n        $tdb-\u003emysql;\n\n postgres\n\n      postgres(Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The postgres method builds and returns a Test::DB::Postgres object.\n\n    postgres example #1\n\n        # given: synopsis\n      \n        $tdb-\u003epostgres;\n\n sqlite\n\n      sqlite(Str %options) : Maybe[InstanceOf[\"Test::DB::Object\"]]\n\n    The sqlite method builds and returns a Test::DB::Sqlite object.\n\n    sqlite example #1\n\n        # given: synopsis\n      \n        $tdb-\u003esqlite;\n\nAUTHOR\n\n    Al Newkirk, awncorp@cpan.org\n\nLICENSE\n\n    Copyright (C) 2011-2019, Al Newkirk, et al.\n\n    This is free software; you can redistribute it and/or modify it under\n    the terms of the The Apache License, Version 2.0, as elucidated in the\n    \"license file\"\n    \u003chttps://github.com/iamalnewkirk/test-db/blob/master/LICENSE\u003e.\n\nPROJECT\n\n    Wiki \u003chttps://github.com/iamalnewkirk/test-db/wiki\u003e\n\n    Project \u003chttps://github.com/iamalnewkirk/test-db\u003e\n\n    Initiatives \u003chttps://github.com/iamalnewkirk/test-db/projects\u003e\n\n    Milestones \u003chttps://github.com/iamalnewkirk/test-db/milestones\u003e\n\n    Contributing\n    \u003chttps://github.com/iamalnewkirk/test-db/blob/master/CONTRIBUTE.md\u003e\n\n    Issues \u003chttps://github.com/iamalnewkirk/test-db/issues\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Ftest-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawncorp%2Ftest-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawncorp%2Ftest-db/lists"}