forked from cantino/my_obfuscate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,23 +28,24 @@ | |
describe "when using Postgres" do | ||
let(:dump) do | ||
StringIO.new(<<-SQL) | ||
COPY some_table (id, email, name, something, age) FROM stdin; | ||
1 hello monkey moose 14 | ||
\. | ||
COPY single_column_table (id) FROM stdin; | ||
1 | ||
2 | ||
\. | ||
COPY another_table (a, b, c, d) FROM stdin; | ||
1 2 3 4 | ||
1 2 3 4 | ||
\. | ||
COPY some_table_to_keep (a, b) FROM stdin; | ||
5 6 | ||
\. | ||
COPY some_table (id, email, name, something, age) FROM stdin; | ||
1 hello monkey moose 14 | ||
\. | ||
COPY single_column_table (id) FROM stdin; | ||
1 | ||
2 | ||
\\N | ||
\. | ||
COPY another_table (a, b, c, d) FROM stdin; | ||
1 2 3 4 | ||
1 2 3 4 | ||
\. | ||
COPY some_table_to_keep (a, b) FROM stdin; | ||
5 6 | ||
\. | ||
SQL | ||
end | ||
|
||
|
@@ -53,10 +54,10 @@ | |
:some_table => { | ||
:email => {:type => :email, :skip_regexes => [/^[\w\.\_]+@honk\.com$/i, /^[email protected]$/]}, | ||
:name => {:type => :string, :length => 8, :chars => MyObfuscate::USERNAME_CHARS}, | ||
:age => {:type => :integer, :between => 10...80} | ||
:age => {:type => :integer, :between => 10...80, :unless => :nil }, | ||
}, | ||
:single_column_table => { | ||
:id => {:type => :integer, :between => 1...8} | ||
:id => {:type => :integer, :between => 1...8, :unless => :nil} | ||
}, | ||
:another_table => :truncate, | ||
:some_table_to_keep => :keep | ||
|
@@ -86,11 +87,15 @@ | |
output_string.should match(/1\t.*\t\S{8}\tmoose\t\d{2}\n/) | ||
end | ||
|
||
it "can skip nils" do | ||
output_string.should match(/\d\n\d\n\\N/) | ||
end | ||
|
||
it "is able to keep tables" do | ||
output_string.should include("5\t6") | ||
end | ||
|
||
context "when dump contains statement" do | ||
context "when dump contains INSERT statement" do | ||
let(:dump) do | ||
StringIO.new(<<-SQL) | ||
INSERT INTO some_table (email, name, something, age) VALUES ('','', '', 25); | ||
|