-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added funcion to test all events from 2017
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0048666
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, let me give you some ideas/questions/observations:
nextDay = new Date(prevDay.getTime() + 24 * 60 * 60 * 1000);
looping this 365 times should let you to walk all the dates in the year much easier;unit-tests.gs
file more than tocode.gs
: this way we (contributors) can have it and use it to test the script, but the users will not copy it over, clobbing an already over-1000 lines script;Nice work!
0048666
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't have better idea to do tests other than just run it through all dates
0048666
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did what you suggested but it handles DST differently. Both of them are in commit b4c6e40 . I'm gonna delete those commit anyway so it doesn't matter that it's in code.gs for now.
My first approach creates something like that
(that's only few dates)
while mine creates something like that
I guess it can make a problem with running a test but I can't check that because I've got blocked mails for today (I've sent 100).
0048666
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply do "File" -> "New" -> "Script File" and create your copy of
unit-tests.gs
. Then you can open ne or the other and execute the function you want to. The trick is that at execution time all the files are merged together in a unique file, so you can safely call functions from different files (e.g. hownew Log()
is called inunit-tests.gs
).The best thing we could do would be developing some kind of test that could be automatically validated or, at least, does not involve sending hundreds of emails...
The only thing I can think of right now, off the top of my head, would be splitting the main() function in two like this:
createEmail()
: collect the data from the contacts and generate the email textsendEmail()
: get the generated text and send the emailThis way we could test the
createEmail()
function without actually sending the emails (maybe grouping all the emails into a single one?)0048666
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GioBonvi
Ok, I've got unit-tests.gs working. Thanks
I guess I did something similar to thing that you mention (commit 67d28cd)
Problem with DST is not a problem because everything works OK (even though half of dates in second method of testing all events from a year is with wrong hour)