From b700c1bef89a67a64f1040fb6bb03c0320eefe91 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Apr 2017 21:55:48 +0200 Subject: Rename database client files to put them in a `Client` module Will be modifying the class names in the next commit. Here we change the file names & locations of the database client files. The format changes thusly: _client.rb -> client/.rb This organisation feels cleaner to me. Wasn't liking the previous structure. --- spec/dbshell/client/database_spec.rb | 26 ++++++++++++++++++++++++++ spec/dbshell/client/postgres_spec.rb | 26 ++++++++++++++++++++++++++ spec/dbshell/client/sqlite3_spec.rb | 16 ++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 spec/dbshell/client/database_spec.rb create mode 100644 spec/dbshell/client/postgres_spec.rb create mode 100644 spec/dbshell/client/sqlite3_spec.rb (limited to 'spec/dbshell/client') diff --git a/spec/dbshell/client/database_spec.rb b/spec/dbshell/client/database_spec.rb new file mode 100644 index 0000000..1659fa3 --- /dev/null +++ b/spec/dbshell/client/database_spec.rb @@ -0,0 +1,26 @@ +require 'minitest/autorun' +require 'dbshell/database_client' + +describe DBShell::DatabaseClient do + describe ".handler" do + it "handles SQLite3" do + DBShell::DatabaseClient.handler({ + 'adapter' => 'sqlite3' + }).must_equal(DBShell::Sqlite3Client) + end + + it "handles Postgres" do + DBShell::DatabaseClient.handler({ + 'adapter' => 'postgresql' + }).must_equal(DBShell::PostgresClient) + end + + it "raises an error if no suitable adapter is found" do + proc do + DBShell::DatabaseClient.handler({ + 'adapter' => 'sybil_system' + }) + end.must_raise(DBShell::InvalidDatabaseAdapter) + end + end +end diff --git a/spec/dbshell/client/postgres_spec.rb b/spec/dbshell/client/postgres_spec.rb new file mode 100644 index 0000000..2f767f1 --- /dev/null +++ b/spec/dbshell/client/postgres_spec.rb @@ -0,0 +1,26 @@ +require 'minitest/autorun' +require 'dbshell/postgres_client' + +describe DBShell::PostgresClient do + describe ".build_command" do + it "builds basic arguments" do + DBShell::PostgresClient.build_command({ + 'adapter' => 'postgresql', + 'host' => 'mailmarehost', + 'port' => 6027, + 'username' => 'derpyhooves', + 'password' => 'somepassword', + 'database' => 'dbname' + }).must_equal([ + 'psql', + '-U', + 'derpyhooves', + '-h', + 'mailmarehost', + '-p', + 6027, + 'dbname' + ]) + end + end +end diff --git a/spec/dbshell/client/sqlite3_spec.rb b/spec/dbshell/client/sqlite3_spec.rb new file mode 100644 index 0000000..4922993 --- /dev/null +++ b/spec/dbshell/client/sqlite3_spec.rb @@ -0,0 +1,16 @@ +require 'minitest/autorun' +require 'dbshell/sqlite3_client' + +describe DBShell::Sqlite3Client do + describe ".build_command" do + it "builds basic arguments" do + DBShell::Sqlite3Client.build_command({ + 'adapter' => 'sqlite3', + 'database' => 'db/development.sqlite3' + }).must_equal([ + 'sqlite3', + 'db/development.sqlite3' + ]) + end + end +end -- cgit v1.2.3