Commit | Line | Data |
8a3edced |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use Test::Deep; |
8 | |
9 | use lib 't/lib'; |
10 | use aliased 'DBIx::Class::DeploymentHandler::Filesystem'; |
11 | |
12 | my $fs = Filesystem->new({ script_directory => 't/filesystem' }); |
13 | |
14 | my @t = ( |
15 | (map +{ meth => '_ddl_schema_consume_filenames', %$_ }, |
16 | { |
17 | args => ['MySQL', 1], |
18 | expected => ['t/filesystem/MySQL/deploy/1/001-auto.sql'], |
19 | }, |
20 | { |
21 | args => ['MySQL', 2], |
22 | expected => ['t/filesystem/MySQL/deploy/2/001-auto.sql'], |
23 | }, |
24 | { |
25 | args => ['MySQL', 3], |
26 | expected => ['t/filesystem/MySQL/deploy/3/001-auto.sql'], |
27 | }, |
28 | { |
29 | args => ['SQLite', 1], |
30 | expected => ['t/filesystem/SQLite/deploy/1/001-auto.sql'], |
31 | }, |
32 | { |
33 | args => ['SQLite', 2], |
34 | expected => ['t/filesystem/SQLite/deploy/2/001-auto.sql'], |
35 | }, |
36 | { |
37 | args => ['SQLite', 3], |
38 | expected => ['t/filesystem/SQLite/deploy/3/001-auto.sql'], |
39 | }), |
40 | |
41 | (map +{ meth => '_ddl_schema_produce_filename', %$_ }, |
42 | { |
43 | args => ['MySQL', 1], |
44 | expected => 't/filesystem/MySQL/deploy/1/001-auto.sql', |
45 | }, |
46 | { |
47 | args => ['MySQL', 2], |
48 | expected => 't/filesystem/MySQL/deploy/2/001-auto.sql', |
49 | }, |
50 | { |
51 | args => ['MySQL', 3], |
52 | expected => 't/filesystem/MySQL/deploy/3/001-auto.sql', |
53 | }, |
54 | { |
55 | args => ['SQLite', 1], |
56 | expected => 't/filesystem/SQLite/deploy/1/001-auto.sql', |
57 | }, |
58 | { |
59 | args => ['SQLite', 2], |
60 | expected => 't/filesystem/SQLite/deploy/2/001-auto.sql', |
61 | }, |
62 | { |
63 | args => ['SQLite', 3], |
64 | expected => 't/filesystem/SQLite/deploy/3/001-auto.sql', |
65 | }), |
66 | |
67 | ( map +{ meth => '_ddl_initialize_consume_filenames', %$_ }, |
68 | { |
69 | args => ['MySQL', 1], |
70 | expected => [ |
71 | 't/filesystem/MySQL/initialize/1/001-create-database.pl', |
72 | 't/filesystem/MySQL/initialize/1/002-create-users.pl' |
73 | ], |
74 | }, { |
75 | args => ['MySQL', 2], |
76 | expected => [ |
77 | 't/filesystem/MySQL/initialize/2/001-create-database.pl', |
78 | 't/filesystem/MySQL/initialize/2/002-create-users.pl' |
79 | ], |
80 | }, { |
81 | args => ['MySQL', 3], |
82 | expected => [ |
83 | 't/filesystem/MySQL/initialize/3/001-create-database.pl', |
84 | 't/filesystem/MySQL/initialize/3/002-create-users.pl' |
85 | ], |
86 | }, { |
87 | args => ['SQLite', 1], |
88 | expected => [ |
89 | 't/filesystem/SQLite/initialize/1/001-create-database.pl', |
90 | 't/filesystem/SQLite/initialize/1/002-create-users.pl' |
91 | ], |
92 | }, { |
93 | args => ['SQLite', 2], |
94 | expected => [ |
95 | 't/filesystem/SQLite/initialize/2/001-create-database.pl', |
96 | 't/filesystem/SQLite/initialize/2/002-create-users.pl' |
97 | ], |
98 | }, { |
99 | args => ['SQLite', 3], |
100 | expected => [ |
101 | 't/filesystem/SQLite/initialize/3/001-create-database.pl', |
102 | 't/filesystem/SQLite/initialize/3/002-create-users.pl' |
103 | ], |
104 | }), |
105 | |
106 | ( map +{ meth => '_ddl_protoschema_deploy_consume_filenames', %$_ }, |
107 | { |
108 | args => [1], |
109 | expected => ['t/filesystem/_source/deploy/1/001-auto.yml'], |
110 | }, { |
111 | args => [2], |
112 | expected => ['t/filesystem/_source/deploy/2/001-auto.yml'], |
113 | }, { |
114 | args => [3], |
115 | expected => ['t/filesystem/_source/deploy/3/001-auto.yml'], |
116 | }), |
117 | |
118 | ( map +{ meth => '_ddl_protoschema_upgrade_consume_filenames', %$_ }, |
119 | { |
120 | args => [[1,2]], |
121 | expected => ['t/filesystem/_preprocess_schema/upgrade/1-2/001-rename-columns.pl'], |
122 | }, { |
123 | args => [[2,3]], |
124 | expected => ['t/filesystem/_preprocess_schema/upgrade/2-3/001-rename-columns.pl'], |
125 | }), |
126 | |
127 | ( map +{ meth => '_ddl_protoschema_downgrade_consume_filenames', %$_ }, |
128 | { |
129 | args => [[2,1]], |
130 | expected => ['t/filesystem/_preprocess_schema/downgrade/2-1/001-rename-columns.pl'], |
131 | }, { |
132 | args => [[3,2]], |
133 | expected => ['t/filesystem/_preprocess_schema/downgrade/3-2/001-rename-columns.pl'], |
134 | }), |
135 | |
136 | ( map +{ meth => '_ddl_protoschema_produce_filename', %$_ }, |
137 | { |
138 | args => [1], |
139 | expected => 't/filesystem/_source/deploy/1/001-auto.yml', |
140 | }, { |
141 | args => [2], |
142 | expected => 't/filesystem/_source/deploy/2/001-auto.yml', |
143 | }, { |
144 | args => [3], |
145 | expected => 't/filesystem/_source/deploy/3/001-auto.yml', |
146 | }), |
147 | |
148 | ( map +{ meth => '_ddl_schema_upgrade_consume_filenames', %$_ }, |
149 | { |
150 | args => ['MySQL', [1,2]], |
151 | expected => ['t/filesystem/MySQL/upgrade/1-2/001-auto.sql'], |
152 | }, |
153 | { |
154 | args => ['MySQL', [2,3]], |
155 | expected => ['t/filesystem/MySQL/upgrade/2-3/001-auto.sql'], |
156 | }, |
157 | { |
158 | args => ['SQLite', [1,2]], |
159 | expected => ['t/filesystem/SQLite/upgrade/1-2/001-auto.sql'], |
160 | }, |
161 | { |
162 | args => ['SQLite', [2,3]], |
163 | expected => ['t/filesystem/SQLite/upgrade/2-3/001-auto.sql'], |
164 | }), |
165 | |
166 | ( map +{ meth => '_ddl_schema_downgrade_consume_filenames', %$_ }, |
167 | { |
168 | args => ['MySQL', [2,1]], |
169 | expected => ['t/filesystem/MySQL/downgrade/2-1/001-auto.sql'], |
170 | }, |
171 | { |
172 | args => ['MySQL', [3,2]], |
173 | expected => ['t/filesystem/MySQL/downgrade/3-2/001-auto.sql'], |
174 | }, |
175 | { |
176 | args => ['SQLite', [2,1]], |
177 | expected => ['t/filesystem/SQLite/downgrade/2-1/001-auto.sql'], |
178 | }, |
179 | { |
180 | args => ['SQLite', [3,2]], |
181 | expected => ['t/filesystem/SQLite/downgrade/3-2/001-auto.sql'], |
182 | }), |
183 | ); |
184 | |
185 | for (@t) { |
186 | my $m = $_->{meth}; |
187 | cmp_deeply |
188 | $fs->$m(@{$_->{args}}), |
189 | $_->{expected}, |
190 | "$m(" . join (', ', map { ref $_ ? '[' . join(', ', @$_) . ']' : $_ } @{$_->{args}}) . ')'; |
191 | } |
192 | |
193 | done_testing; |