1
00:00:02,670 --> 00:00:07,740
So now that we were sending emails, we probably should run our tests just to make sure things work

2
00:00:07,740 --> 00:00:14,340
as expected and as you'll quickly discover and I'm in my handler's folder inside the internal package

3
00:00:14,700 --> 00:00:22,230
right here, when I run the tests, go test dash v dot, you're going to see it doesn't quite work the

4
00:00:22,230 --> 00:00:23,070
way you expect.

5
00:00:24,060 --> 00:00:27,920
It stops at Test Repository Post Reservation.

6
00:00:28,350 --> 00:00:32,340
And not surprisingly, that's the function we just made a bunch of changes to.

7
00:00:32,340 --> 00:00:34,340
We made some changes to send a couple of emails.

8
00:00:34,830 --> 00:00:37,380
So let's figure out why it's stopping there.

9
00:00:38,370 --> 00:00:46,500
If you look at our setup test for this package, our test made, we registered the models reservation

10
00:00:46,500 --> 00:00:48,300
that we're going to be putting in this session, which is great.

11
00:00:48,300 --> 00:00:50,400
We set some variables in the app.

12
00:00:50,400 --> 00:00:51,600
We set up our logger's.

13
00:00:52,050 --> 00:00:55,350
We'd make sure our session is populated in the opt out session.

14
00:00:55,560 --> 00:00:58,200
We create the template cache, all of these things.

15
00:00:58,350 --> 00:01:05,490
Now, one thing that's missing from this that exists over in May not go is something we set up that

16
00:01:05,490 --> 00:01:07,020
says, listen for mail.

17
00:01:07,320 --> 00:01:10,840
And of course, that function sends things to the mail channel.

18
00:01:11,520 --> 00:01:17,100
Now, when I'm running this test for the handler, I don't actually want to make sure that email goes.

19
00:01:17,400 --> 00:01:24,120
I can do that separately by testing the mail package itself for the testing, the send mail go file

20
00:01:24,120 --> 00:01:25,940
in the main package.

21
00:01:26,520 --> 00:01:32,040
So instead, I need to duplicate this functionality and have it not actually send mail.

22
00:01:32,680 --> 00:01:37,320
So what I'm going to do on the setup test go is about here.

23
00:01:38,160 --> 00:01:43,200
Before I create the template cache, I'm going to set up a mail chain mail channel.

24
00:01:43,710 --> 00:01:47,910
It will be an actual channel and it will be just like we did in the in the main package.

25
00:01:47,910 --> 00:01:51,830
It will make a CHANNE models dot mail data.

26
00:01:52,470 --> 00:01:57,630
So I have that channel and then I'll set my app Milchan to that variable.

27
00:01:57,630 --> 00:02:04,170
I just created that channel I just created, which works great and I will defer the close of that channel.

28
00:02:08,360 --> 00:02:12,740
As I should, and then I'm going to call a function that doesn't exist yet, I don't want to create

29
00:02:12,740 --> 00:02:13,360
that in a moment.

30
00:02:13,910 --> 00:02:15,680
Listen for male.

31
00:02:21,990 --> 00:02:27,540
So this is going to duplicate the functionality that we do in our actual live application, so let's

32
00:02:27,540 --> 00:02:30,170
create that function and I will create it.

33
00:02:30,180 --> 00:02:32,790
I will call it listen for male.

34
00:02:34,370 --> 00:02:39,710
And it's going to do pretty much the same thing that we do in our live application, but I'm going to

35
00:02:39,710 --> 00:02:42,020
skip the actual sending of mail.

36
00:02:42,050 --> 00:02:45,620
OK, so I will say go funk, just like I do in the other one.

37
00:02:47,310 --> 00:02:49,250
Let her get the parentheses right.

38
00:02:55,690 --> 00:03:01,630
And I will put a for loop that runs forever until the application stops running, and inside of that

39
00:03:01,630 --> 00:03:07,420
I will actually handle but do nothing with anything that is sent to the mail channel.

40
00:03:12,000 --> 00:03:13,760
Now, I have a typo here somewhere.

41
00:03:15,330 --> 00:03:19,720
There it is, closing parentheses after that anonymous function.

42
00:03:20,340 --> 00:03:27,150
Now now that I have this set up, I actually do have a means of doing something that I send to the mail

43
00:03:27,150 --> 00:03:27,500
channel.

44
00:03:27,810 --> 00:03:31,770
But I'm going to ignore I'm just going to say, OK, I got something from the male friend, but do nothing

45
00:03:31,770 --> 00:03:32,100
with it.

46
00:03:32,910 --> 00:03:41,640
So let's try running those tests again, clear the screen, go run or go test dashboard in the handler's

47
00:03:41,640 --> 00:03:42,030
folder.

48
00:03:44,310 --> 00:03:50,070
And they all pass, and that's all we have to do, so again, any time you need to, anytime you make

49
00:03:50,070 --> 00:03:56,220
a change to a function or change to your code base, always run your tests, make sure you need that.

50
00:03:56,220 --> 00:03:59,000
You don't need to update them because you usually do need to update them.

51
00:03:59,340 --> 00:04:05,610
And as is the case here, all I need to do is to mark that functionality that exists in the main program.

52
00:04:05,830 --> 00:04:11,100
I just need to make sure that if I'm trying to send something to a channel and listening for the response,

53
00:04:11,370 --> 00:04:16,310
then I'd better actually implement that functionality in my setup Tesco file.

54
00:04:16,320 --> 00:04:17,240
And that's all there is to it.
