Skip to content

Commit

Permalink
add test case for surveyor message
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Apr 17, 2019
1 parent 7b4f745 commit f576ff0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ func TestCreateMsgArchive(t *testing.T) {
assert.NoError(t, err)

// should have two records, second will have attachments
assert.Equal(t, 5, task.RecordCount)
assert.Equal(t, int64(633), task.Size)
assert.Equal(t, 6, task.RecordCount)
assert.Equal(t, int64(646), task.Size)
assert.Equal(t, time.Date(2017, 8, 12, 0, 0, 0, 0, time.UTC), task.StartDate)
assert.Equal(t, "079ac762aad71d5489a5dbcc97aef36a", task.Hash)
assert.Equal(t, "5fe5adcd696342367bdc9b877e524f4a", task.Hash)
assertArchiveFile(t, task, "messages1.jsonl")

DeleteArchiveFile(task)
Expand Down Expand Up @@ -316,9 +316,9 @@ func TestArchiveOrgMessages(t *testing.T) {

assert.Equal(t, time.Date(2017, 8, 12, 0, 0, 0, 0, time.UTC), created[2].StartDate)
assert.Equal(t, DayPeriod, created[2].Period)
assert.Equal(t, 5, created[2].RecordCount)
assert.Equal(t, int64(633), created[2].Size)
assert.Equal(t, "079ac762aad71d5489a5dbcc97aef36a", created[2].Hash)
assert.Equal(t, 6, created[2].RecordCount)
assert.Equal(t, int64(646), created[2].Size)
assert.Equal(t, "5fe5adcd696342367bdc9b877e524f4a", created[2].Hash)

assert.Equal(t, time.Date(2017, 8, 13, 0, 0, 0, 0, time.UTC), created[3].StartDate)
assert.Equal(t, DayPeriod, created[3].Period)
Expand All @@ -334,9 +334,9 @@ func TestArchiveOrgMessages(t *testing.T) {

assert.Equal(t, time.Date(2017, 8, 1, 0, 0, 0, 0, time.UTC), created[61].StartDate)
assert.Equal(t, MonthPeriod, created[61].Period)
assert.Equal(t, 6, created[61].RecordCount)
assert.Equal(t, int64(657), created[61].Size)
assert.Equal(t, "fbeb0de984b76bf24609bf2139cf8553", created[61].Hash)
assert.Equal(t, 7, created[61].RecordCount)
assert.Equal(t, int64(670), created[61].Size)
assert.Equal(t, "0677e49245b792664d75e9b3aebb4455", created[61].Hash)

assert.Equal(t, time.Date(2017, 9, 1, 0, 0, 0, 0, time.UTC), created[62].StartDate)
assert.Equal(t, MonthPeriod, created[62].Period)
Expand Down
1 change: 1 addition & 0 deletions testdata/messages1.jsonl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{"id":1,"broadcast":null,"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"urn":"tel:+12067797777","channel":{"uuid":"60f2ed5b-05f2-4156-9ff0-e44e90da1b85","name":"Channel 2"},"direction":"in","type":"inbox","status":"handled","visibility":"visible","text":"message 1","attachments":[],"labels":[{"name": "Label 1", "uuid": "1d9e3188-b74b-4ae0-a166-0de31aedb34a"}, {"name": "Label 2", "uuid": "c5a69101-8dc3-444f-8b0b-5ab816e46eec"}],"created_on":"2017-08-12T21:11:59.890662+00:00","sent_on":"2017-08-12T21:11:59.890662+00:00","modified_on":"2017-08-12T21:11:59.890662+00:00"}
{"id":3,"broadcast":null,"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"urn":"tel:+12067797777","channel":null,"direction":"out","type":"inbox","status":"handled","visibility":"visible","text":"message 3","attachments":[{"url": "https://foo.bar/image1.png", "content_type": "image/png"}, {"url": "https://foo.bar/image2.png", "content_type": "image/png"}],"labels":[{"name": "Label 2", "uuid": "c5a69101-8dc3-444f-8b0b-5ab816e46eec"}],"created_on":"2017-08-12T21:11:59.890662+00:00","sent_on":"2017-08-12T21:11:59.890662+00:00","modified_on":"2017-08-12T21:11:59.890662+00:00"}
{"id":9,"broadcast":null,"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"urn":null,"channel":null,"direction":"out","type":"flow","status":"sent","visibility":"visible","text":"message 9","attachments":[],"labels":[],"created_on":"2017-08-12T21:11:59.890662+00:00","sent_on":"2017-08-12T21:11:59.890662+00:00","modified_on":"2017-08-12T21:11:59.890662+00:00"}
{"id":null,"broadcast":1,"contact":{"name": "John Arbies", "uuid": "2b8bd28d-43e0-4c34-a4bb-0f10b11fdb8a"},"text":"hello","urn":null,"channel":null,"direction":"out","type":"flow","status":"wired","visibility":"visible","attachments":[],"labels":[],"created_on":"2017-08-12T20:11:59.890662+00:00","sent_on":"2017-08-12T20:11:59.890662+00:00","modified_on":"2017-08-12T20:11:59.890662+00:00"}
{"id":null,"broadcast":1,"contact":{"name": null, "uuid": "b46f6e18-95b4-4984-9926-dded047f4eb3"},"text":"bonjour","urn":null,"channel":null,"direction":"out","type":"flow","status":"delivered","visibility":"visible","attachments":[],"labels":[],"created_on":"2017-08-12T20:11:59.890662+00:00","sent_on":"2017-08-12T20:11:59.890662+00:00","modified_on":"2017-08-12T20:11:59.890662+00:00"}
{"id":null,"broadcast":2,"contact":{"name": null, "uuid": "9195c8b7-6138-4d84-ac56-5192cc3d8ceb"},"text":"hola","urn":null,"channel":null,"direction":"out","type":"flow","status":"wired","visibility":"visible","attachments":[],"labels":[],"created_on":"2017-08-12T20:11:59.890662+00:00","sent_on":"2017-08-12T20:11:59.890662+00:00","modified_on":"2017-08-12T20:11:59.890662+00:00"}
5 changes: 3 additions & 2 deletions testdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ CREATE TABLE msgs_msg (
attachments character varying(255)[],
channel_id integer references channels_channel(id) on delete cascade,
contact_id integer NOT NULL references contacts_contact(id) on delete cascade,
contact_urn_id integer NOT NULL references contacts_contacturn(id) on delete cascade,
contact_urn_id integer NULL references contacts_contacturn(id) on delete cascade,
org_id integer NOT NULL references orgs_org(id) on delete cascade,
metadata text,
topup_id integer,
Expand Down Expand Up @@ -281,7 +281,8 @@ INSERT INTO msgs_msg(id, broadcast_id, uuid, text, created_on, sent_on, modified
(5, NULL, 'f557972e-2eb5-42fa-9b87-902116d18787', 'message 5', '2017-08-11 21:11:59.890662+02:00', '2017-08-11 21:11:59.890662+02:00', '2017-08-11 21:11:59.890662+02:00', 'I', 'H', 'V', 'I', NULL, 3, 7, 8, 3, 1, 0, '2017-08-11 21:11:59.890662+02:00', NULL),
(6, NULL, '579d148c-0ab1-4afb-832f-afb1fe0e19b7', 'message 6', '2017-10-08 21:11:59.890662+00', '2017-10-08 21:11:59.890662+00', '2017-10-08 21:11:59.890662+00', 'I', 'H', 'V', 'I', NULL, 2, 6, 7, 2, 1, 0, '2017-10-08 21:11:59.890662+00', NULL),
(7, NULL, '7aeca469-2593-444e-afe4-4702317534c9', 'message 7', '2018-01-02 21:11:59.890662+00', '2018-01-02 21:11:59.890662+00', '2018-01-02 21:11:59.890662+00', 'I', 'H', 'V', 'I', NULL, 2, 6, 7, 2, 1, 0, '2018-01-02 21:11:59.890662+00', 2),
(8, NULL, '48fab92b-6d75-45c8-9121-81176d97bdbf', 'message 8', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', 'I', 'H', 'V', 'I', NULL, 2, 11, 7, 2, 1, 0, '2017-08-12 21:11:59.890662+00', NULL);
(8, NULL, '48fab92b-6d75-45c8-9121-81176d97bdbf', 'message 8', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', 'I', 'H', 'V', 'I', NULL, 2, 11, 7, 2, 1, 0, '2017-08-12 21:11:59.890662+00', NULL),
(9, NULL, 'e14ab466-0d3b-436d-a0f7-5851fd7d9b7d', 'message 9', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', '2017-08-12 21:11:59.890662+00', 'O', 'S', 'V', 'F', NULL, NULL, 6, NULL, 2, 1, 0, '2017-08-12 21:11:59.890662+00', NULL);

INSERT INTO msgs_label(id, uuid, name) VALUES
(1, '1d9e3188-b74b-4ae0-a166-0de31aedb34a', 'Label 1'),
Expand Down

0 comments on commit f576ff0

Please sign in to comment.