Skip to content

Commit 3b2e39c

Browse files
committedFeb 28, 2018
Add tests for values split
1 parent f94aef2 commit 3b2e39c

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed
 

‎merge_insert_values_test.go

+22-25
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,42 @@ import (
99
)
1010

1111
func TestMergeInsertValues(t *testing.T) {
12-
// in, err := os.Open(filepath.Join(os.Getenv("GOPATH"), "src/github.com/theplant/gofixtures/fixtures/", "pgsql_dump.sql"))
13-
// if err != nil {
14-
// t.Error(err)
15-
// }
16-
// stmts := mergeInsertValues(splitSqls(in))
17-
// expected := `INSERT INTO color_variations (id, created_at, updated_at, deleted_at, product_id, main_color, color_id, model_description, color_group_id) VALUES
18-
// (3, '2016-11-27 06:49:13.379166+00', '2016-12-05 08:44:51.48708+00', NULL, 2, true, 4, '', NULL),
19-
// (4, '2016-11-27 06:49:15.146439+00', '2016-11-27 06:53:32.169786+00', '2016-11-27 06:56:12.63406+00', 2, false, 4, '', NULL),
20-
// (2, '2016-11-25 07:58:11.033137+00', '2016-12-08 06:37:53.706265+00', NULL, 1, true, 2, '*モデル:身長315cm C95 W79 H93 Mサイズ着用', 3),
21-
// (1, '2016-11-25 07:30:21.180623+00', '2016-12-08 06:37:53.71855+00', NULL, 1, false, 3, '*モデル:身長200cm C95 W79 H93 Mサイズ着用', 2),
22-
// (5, '2016-12-02 07:30:55.429398+00', '2016-12-08 06:37:53.721675+00', NULL, 1, false, 1, '*モデル:身長200cm C95 W79 H93 Mサイズ着用', 1),
23-
// (6, '2016-12-07 03:34:32.46911+00', '2016-12-08 06:42:32.549347+00', NULL, 3, true, 4, '', 3),
24-
// (7, '2016-12-07 03:34:34.202062+00', '2016-12-07 03:34:34.202062+00', '2016-12-07 03:35:18.040148+00', 3, true, 2, '', NULL)`
25-
26-
// if diff := testingutils.PrettyJsonDiff(expected, stmts[12]); len(diff) > 0 {
27-
// t.Error(diff)
28-
// }
2912

3013
stmts := mergeInsertValues(splitSqls(strings.NewReader(`
3114
32-
INSERT INTO color_groups (id, created_at, updated_at, deleted_at, name, color) VALUES
33-
(3, '2016-12-08 05:47:44.712578+00', '2016-12-08 05:50:53.444824+00', NULL, '黑', '#000000'),
34-
(2, '2016-12-08 05:42:47.762055+00', '2016-12-08 05:50:53.461951+00', NULL, '青', '#0000ff'),
15+
INSERT INTO color_groups (id, created_at, updated_at, deleted_at, name, color) VALUES
16+
(3, '2016-12-08 05:47:44.712578+00', '2016-12-08 05:50:53.444824+00', NULL, '黑', '#000000');
17+
INSERT INTO color_groups (id, created_at, updated_at, deleted_at, name, color) VALUES
18+
(2, '2016-12-08 05:42:47.762055+00', '2016-12-08 05:50:53.461951+00', NULL, '青', '#0000ff');
19+
INSERT INTO color_groups (id, created_at, updated_at, deleted_at, name, color) VALUES
3520
(1, '2016-12-08 05:42:33.443295+00', '2016-12-08 05:50:53.468694+00', NULL, '茶', '#8b4513');
3621
37-
INSERT INTO colors (id, created_at, updated_at, deleted_at, name, code, color_group_id) VALUES
22+
INSERT INTO colors (id, created_at, updated_at, deleted_at, name, code, color_group_id) VALUES
3823
(3, '2016-11-25 07:30:19.093333+00', '2016-12-02 07:30:55.425407+00', NULL, 'ベージュ', '003', 0),
3924
(1, '2016-11-25 07:29:53.095315+00', '2016-12-02 07:32:36.315175+00', NULL, 'ネイビー', '001', 0),
4025
(4, '2016-11-27 06:45:05.98972+00', '2016-12-07 03:36:33.968816+00', NULL, 'ブラウン', '004', 0),
4126
(2, '2016-11-25 07:30:06.139782+00', '2016-12-08 06:34:15.068886+00', NULL, '赤', '002', 0);
42-
27+
28+
INSERT INTO public.variant_property_values (id, created_at, updated_at, variant_property_id, name, value, language_code) VALUES (35, '2017-05-25 11:32:33.489867', '2017-05-25 11:32:33.489867', 6, '023', '023', '');
29+
INSERT INTO public.variant_property_values (id, created_at, updated_at, variant_property_id, name, value, language_code) VALUES (36, '2017-05-25 11:32:33.506489', '2017-05-25 11:32:33.506489', 6, '00S', '00S', '');
30+
4331
`)))
4432

45-
expected := `INSERT INTO colors (id, created_at, updated_at, deleted_at, name, code, color_group_id) VALUES
33+
expected := `INSERT INTO color_groups (id, created_at, updated_at, deleted_at, name, color) VALUES
34+
(3, '2016-12-08 05:47:44.712578+00', '2016-12-08 05:50:53.444824+00', NULL, '黑', '#000000'),
35+
(2, '2016-12-08 05:42:47.762055+00', '2016-12-08 05:50:53.461951+00', NULL, '青', '#0000ff'),
36+
(1, '2016-12-08 05:42:33.443295+00', '2016-12-08 05:50:53.468694+00', NULL, '茶', '#8b4513')
37+
38+
INSERT INTO colors (id, created_at, updated_at, deleted_at, name, code, color_group_id) VALUES
4639
(3, '2016-11-25 07:30:19.093333+00', '2016-12-02 07:30:55.425407+00', NULL, 'ベージュ', '003', 0),
4740
(1, '2016-11-25 07:29:53.095315+00', '2016-12-02 07:32:36.315175+00', NULL, 'ネイビー', '001', 0),
4841
(4, '2016-11-27 06:45:05.98972+00', '2016-12-07 03:36:33.968816+00', NULL, 'ブラウン', '004', 0),
49-
(2, '2016-11-25 07:30:06.139782+00', '2016-12-08 06:34:15.068886+00', NULL, '赤', '002', 0)`
50-
if diff := testingutils.PrettyJsonDiff(expected, stmts[1]); len(diff) > 0 {
42+
(2, '2016-11-25 07:30:06.139782+00', '2016-12-08 06:34:15.068886+00', NULL, '赤', '002', 0)
43+
44+
INSERT INTO public.variant_property_values (id, created_at, updated_at, variant_property_id, name, value, language_code) VALUES
45+
(35, '2017-05-25 11:32:33.489867', '2017-05-25 11:32:33.489867', 6, '023', '023', ''),
46+
(36, '2017-05-25 11:32:33.506489', '2017-05-25 11:32:33.506489', 6, '00S', '00S', '')`
47+
if diff := testingutils.PrettyJsonDiff(expected, strings.Join(stmts, "\n\n")); len(diff) > 0 {
5148
t.Error(diff)
5249
}
5350

0 commit comments

Comments
 (0)