From d2cdc550a376aa55a5b99035a405667a8d6cbdce Mon Sep 17 00:00:00 2001 From: Tyler Britten <1933680+tybritten@users.noreply.github.com> Date: Wed, 8 Jan 2020 11:58:36 -0500 Subject: [PATCH] added tests for changing the archivelength --- archiver_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/archiver_test.go b/archiver_test.go index d3225cf..1ea744d 100644 --- a/archiver_test.go +++ b/archiver_test.go @@ -59,6 +59,22 @@ func TestGetMissingDayArchives(t *testing.T) { assert.Equal(t, time.Date(2017, 8, 11, 0, 0, 0, 0, time.UTC), tasks[0].StartDate) assert.Equal(t, time.Date(2017, 10, 1, 0, 0, 0, 0, time.UTC), tasks[21].StartDate) assert.Equal(t, time.Date(2017, 10, 10, 0, 0, 0, 0, time.UTC), tasks[30].StartDate) + + // org 3 again, but changing the archive period so we have no tasks + orgs[2].ActiveDays = 200 + tasks, err = GetMissingDailyArchives(ctx, db, now, orgs[2], MessageType) + assert.NoError(t, err) + assert.Equal(t, 0, len(tasks)) + + // org 1 again, but lowering the archive period so we have tasks + orgs[0].ActiveDays = 2 + tasks, err = GetMissingDailyArchives(ctx, db, now, orgs[0], MessageType) + assert.NoError(t, err) + assert.Equal(t, 58, len(tasks)) + assert.Equal(t, time.Date(2017, 11, 10, 0, 0, 0, 0, time.UTC), tasks[0].StartDate) + assert.Equal(t, time.Date(2017, 12, 1, 0, 0, 0, 0, time.UTC), tasks[21].StartDate) + assert.Equal(t, time.Date(2017, 12, 10, 0, 0, 0, 0, time.UTC), tasks[30].StartDate) + } func TestGetMissingMonthArchives(t *testing.T) { @@ -89,6 +105,7 @@ func TestGetMissingMonthArchives(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 1, len(tasks)) assert.Equal(t, time.Date(2017, 8, 1, 0, 0, 0, 0, time.UTC), tasks[0].StartDate) + } func TestCreateMsgArchive(t *testing.T) {