forked from ebhomengo/niki
1
0
Fork 0

fix(niki): end2end test seed cleanup problem

This commit is contained in:
Ruhollah 2024-08-24 01:18:07 +03:30
parent ee85bd604c
commit 013fd8cf5c
18 changed files with 109 additions and 214 deletions

View File

@ -101,7 +101,7 @@ func (t *TestContainer) Start() {
// pulls mariaDB image, creates a container based on it and runs it // pulls mariaDB image, creates a container based on it and runs it
t.mariaResource, err = t.dockerPool.RunWithOptions( t.mariaResource, err = t.dockerPool.RunWithOptions(
&dockertest.RunOptions{ &dockertest.RunOptions{
Repository: "mariadb", Repository: "bitnami/mariadb",
Tag: "11.1", Tag: "11.1",
Env: []string{"MARIADB_ROOT_PASSWORD=secret"}, Env: []string{"MARIADB_ROOT_PASSWORD=secret"},
}, func(config *docker.HostConfig) { }, func(config *docker.HostConfig) {
@ -122,7 +122,7 @@ func (t *TestContainer) Start() {
t.redisResource, err = t.dockerPool.RunWithOptions( t.redisResource, err = t.dockerPool.RunWithOptions(
&dockertest.RunOptions{ &dockertest.RunOptions{
Repository: "redis", Repository: "bitnami/redis",
Tag: "6.2", Tag: "6.2",
Env: []string{"ALLOW_EMPTY_PASSWORD=yes"}, Env: []string{"ALLOW_EMPTY_PASSWORD=yes"},
}, func(config *docker.HostConfig) { }, func(config *docker.HostConfig) {

View File

@ -1,16 +0,0 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `description`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`)
VALUES (
3,
1,
'on-table',
100,
'too many!',
'rejected',
1,
NOW() + INTERVAL 7 DAY,
1
);
-- +migrate Down
DELETE FROM `kind_box_reqs` WHERE id = 3;

View File

@ -1,17 +0,0 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `count_accepted`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`, `sender_agent_id`)
VALUES (
4,
1,
'on-table',
1,
1,
'assigned-sender-agent',
1,
NOW() + INTERVAL 7 DAY,
1,
1
);
-- +migrate Down
DELETE FROM `kind_box_reqs` WHERE id = 4;

View File

@ -1,18 +0,0 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `count_accepted`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`, `sender_agent_id`, `delivered_at`)
VALUES (
5,
1,
'on-table',
1,
1,
'delivered',
1,
NOW() - INTERVAL 7 DAY,
1,
1,
NOW()
);
-- +migrate Down
DELETE FROM `kind_box_reqs` WHERE id = 5;

View File

@ -1,18 +0,0 @@
-- +migrate Up
INSERT INTO `admins` (`id`, `first_name`, `last_name`, `password`, `phone_number`, `role`, `description`, `email`, `gender`, `status`)
VALUES (
2,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$UggC7sgECCaNm2TAkchve.TLcHJuxPAVZkzMfCDZqKRQVHcJZaoX2',
'09384664401',
'super-admin',
'testing',
'admin.superadmin.01@gmail.com',
'male',
'active'
);
-- +migrate Dow
DELETE FROM `admins` WHERE id = 2;

View File

@ -0,0 +1,48 @@
-- +migrate Up
INSERT INTO `admins` (`id`, `first_name`, `last_name`, `password`, `phone_number`, `role`, `description`, `email`, `gender`, `status`)
VALUES
-- super admin
(
2,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$UggC7sgECCaNm2TAkchve.TLcHJuxPAVZkzMfCDZqKRQVHcJZaoX2',
'09384664401',
'super-admin',
'testing',
'admin.superadmin.01@gmail.com',
'male',
'active'
),
-- admin
(
3,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$xaNwJqcuRUlPhAUPZhhV3.WRmI5iBea5RzvL4qWS6OCFk0F7bKvaW',
'09384664402',
'admin',
'testing',
'admin.admin.01@gmail.com',
'male',
'active'
),
-- agent
(
4,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$A4qiAep9OGYe2aFT3Tn1cuJfj99Xp6WA2F0SN9I7zAS01JGFU7XAO',
'09384664403',
'agent',
'testing',
'admin.agent.01@gmail.com',
'male',
'active'
);
-- +migrate Down
DELETE FROM `admins` WHERE id != 1;

View File

@ -1,18 +0,0 @@
-- +migrate Up
INSERT INTO `admins` (`id`, `first_name`, `last_name`, `password`, `phone_number`, `role`, `description`, `email`, `gender`, `status`)
VALUES (
3,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$xaNwJqcuRUlPhAUPZhhV3.WRmI5iBea5RzvL4qWS6OCFk0F7bKvaW',
'09384664402',
'admin',
'testing',
'admin.admin.01@gmail.com',
'male',
'active'
);
-- +migrate Down
DELETE FROM `admins` WHERE id = 3;

View File

@ -0,0 +1,28 @@
-- +migrate Up
INSERT INTO `benefactors` (`id`, `first_name`, `last_name`, `phone_number`, `description`, `email`, `gender`, `birth_date`)
VALUES
-- benefactor 1
(
1,
'ruhi',
'hosseini',
'09384664404',
'testing',
'benefactor.01@gmail.com',
'male',
'1998-05-02 04:20:00'
),
-- benefactor 2
(
2,
'doctor',
'who',
'09384664405',
'testing',
'benefactor.02@gmail.com',
'male',
'2000-05-02 04:20:00'
);
-- +migrate Down
DELETE FROM `benefactors`;

View File

@ -0,0 +1,10 @@
-- +migrate Up
INSERT INTO `addresses` (`id`, `postal_code`, `address`, `lat`, `lon`, `name`, `city_id`, `province_id`, `benefactor_id`)
VALUES
-- address 1
(1, '3719655861', 'tehran sare koche 1', 35.632508, 51.452859, 'home1', 8, 8, 1),
-- address 2
(2, '3719655869', 'tehran sare koche 2', 35.735638, 51.312945, 'home2', 8, 8, 2);
-- +migrate Down
DELETE FROM `addresses`;

View File

@ -1,18 +0,0 @@
-- +migrate Up
INSERT INTO `admins` (`id`, `first_name`, `last_name`, `password`, `phone_number`, `role`, `description`, `email`, `gender`, `status`)
VALUES (
4,
'ruhi',
'hosseini',
-- password is: Abc123456
'$2a$10$A4qiAep9OGYe2aFT3Tn1cuJfj99Xp6WA2F0SN9I7zAS01JGFU7XAO',
'09384664403',
'agent',
'testing',
'admin.agent.01@gmail.com',
'male',
'active'
);
-- +migrate Down
DELETE FROM `admins` WHERE id = 4;

View File

@ -1,15 +0,0 @@
-- +migrate Up
INSERT INTO `benefactors` (`id`, `first_name`, `last_name`, `phone_number`, `description`, `email`, `gender`, `birth_date`)
VALUES (
1,
'ruhi',
'hosseini',
'09384664404',
'testing',
'benefactor.01@gmail.com',
'male',
'1998-05-02 04:20:00'
);
-- +migrate Down
DELETE FROM `benefactors` WHERE id = 1;

View File

@ -0,0 +1,17 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `count_accepted`, `description`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`, `sender_agent_id`, `delivered_at`)
VALUES
-- pending kindboxreq for benefactor 1
(1, 1, 'on-table', 1, NULL, NULL, 'pending', 1, NOW() + INTERVAL 7 DAY, 1, NULL, NULL),
-- accepted kindboxreq for benefactor 1
(2, 1, 'on-table', 2, 1, NULL, 'accepted', 1, NOW() + INTERVAL 7 DAY, 1, NULL, NULL),
-- rejected kindboxreq for benefactor 1
(3, 1, 'on-table', 100, NULL, 'too many!', 'rejected', 1, NOW() + INTERVAL 7 DAY, 1, NULL, NULL),
-- assigned sender agent kindboxreq for benefactor 1
(4, 1, 'on-table', 1, 1, NULL, 'assigned-sender-agent', 1, NOW() + INTERVAL 7 DAY, 1, 1, NULL),
-- delivered kindboxreq for benefactor 1
(5, 1, 'on-table', 1, 1, NULL, 'delivered', 1, NOW() - INTERVAL 7 DAY, 1, 1, NOW());
-- +migrate Down
DELETE FROM `kind_box_reqs`;

View File

@ -1,15 +0,0 @@
-- +migrate Up
INSERT INTO `benefactors` (`id`, `first_name`, `last_name`, `phone_number`, `description`, `email`, `gender`, `birth_date`)
VALUES (
2,
'doctor',
'who',
'09384664405',
'testing',
'benefactor.02@gmail.com',
'male',
'2000-05-02 04:20:00'
);
-- +migrate Down
DELETE FROM `benefactors` WHERE id = 2;

View File

@ -1,18 +1,8 @@
-- +migrate Up -- +migrate Up
INSERT INTO `kind_boxes` (`id`, `kind_box_req_id`, `benefactor_id`, `type`, `serial_number`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`, `sender_agent_id`, `delivered_at`) INSERT INTO `kind_boxes` (`id`, `kind_box_req_id`, `benefactor_id`, `type`, `serial_number`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`, `sender_agent_id`, `delivered_at`)
VALUES ( VALUES
1, -- delivered kindbox for benefactor 1
1, (1, 1, 1, 'on-table', 'serial-1', 'delivered', 1, NOW() - INTERVAL 7 DAY, 1, 1, NOW());
1,
'on-table',
'serial-1',
'delivered',
1,
NOW() - INTERVAL 7 DAY,
1,
1,
NOW()
);
-- +migrate Down -- +migrate Down
DELETE FROM `kind_boxes` WHERE id = 1; DELETE FROM `kind_boxes`;

View File

@ -1,16 +0,0 @@
-- +migrate Up
INSERT INTO `addresses` (`id`, `postal_code`, `address`, `lat`, `lon`, `name`, `city_id`, `province_id`, `benefactor_id`)
VALUES (
1,
'3719655861',
'tehran sare koche 1',
35.632508,
51.452859,
'home1',
8,
8,
1
);
-- +migrate Down
DELETE FROM `addresses` WHERE id = 1;

View File

@ -1,16 +0,0 @@
-- +migrate Up
INSERT INTO `addresses` (`id`, `postal_code`, `address`, `lat`, `lon`, `name`, `city_id`, `province_id`, `benefactor_id`)
VALUES (
2,
'3719655869',
'tehran sare koche 2',
35.735638,
51.312945,
'home2',
8,
8,
2
);
-- +migrate Down
DELETE FROM `addresses` WHERE id = 2;

View File

@ -1,15 +0,0 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`)
VALUES (
1,
1,
'on-table',
1,
'pending',
1,
NOW() + INTERVAL 7 DAY,
1
);
-- +migrate Down
DELETE FROM `kind_box_reqs` WHERE id = 1;

View File

@ -1,16 +0,0 @@
-- +migrate Up
INSERT INTO `kind_box_reqs` (`id`, `benefactor_id`, `kind_box_type`, `count_requested`, `count_accepted`, `status`, `deliver_refer_time_id`, `deliver_refer_date`, `deliver_address_id`)
VALUES (
2,
1,
'on-table',
2,
1,
'accepted',
1,
NOW() + INTERVAL 7 DAY,
1
);
-- +migrate Down
DELETE FROM `kind_box_reqs` WHERE id = 2;