forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapgdiff.rb
57 lines (46 loc) · 1.38 KB
/
apgdiff.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Apgdiff < Formula
desc "Another PostgreSQL diff tool"
homepage "http://www.apgdiff.com/"
url "http://www.apgdiff.com/download/apgdiff-2.4-bin.zip"
sha256 "12d95fbb0b8188d7f90e7aaf8bdd29d0eecac26e08d6323624b5b7e3f7c7a3f7"
head do
url "https://github.com/fordfrog/apgdiff.git"
depends_on "ant" => :build
end
bottle :unneeded
def install
jar = "apgdiff-#{version}.jar"
if build.head?
system "ant"
cd "dist" do
jar = Dir["apgdiff-*.jar"].first
mv jar, ".."
end
end
libexec.install jar
bin.write_jar_script libexec/jar, "apgdiff"
end
test do
sql_orig = testpath/"orig.sql"
sql_new = testpath/"new.sql"
sql_orig.write <<-EOS.undent
SET search_path = public, pg_catalog;
SET default_tablespace = '';
CREATE TABLE testtable (field1 integer);
ALTER TABLE public.testtable OWNER TO fordfrog;
EOS
sql_new.write <<-EOS.undent
SET search_path = public, pg_catalog;
SET default_tablespace = '';
CREATE TABLE testtable (field1 integer,
field2 boolean DEFAULT false NOT NULL);
ALTER TABLE public.testtable OWNER TO fordfrog;
EOS
expected = <<-EOS.undent.strip
ALTER TABLE testtable
\tADD COLUMN field2 boolean DEFAULT false NOT NULL;
EOS
result = pipe_output("#{bin}/apgdiff #{sql_orig} #{sql_new}").strip
assert_equal result, expected
end
end