So now that we were sending emails, we probably should run our tests just to make sure things work
as expected and as you'll quickly discover and I'm in my handler's folder inside the internal package
right here, when I run the tests, go test dash v dot, you're going to see it doesn't quite work the
way you expect.
It stops at Test Repository Post Reservation.
And not surprisingly, that's the function we just made a bunch of changes to.
We made some changes to send a couple of emails.
So let's figure out why it's stopping there.
If you look at our setup test for this package, our test made, we registered the models reservation
that we're going to be putting in this session, which is great.
We set some variables in the app.
We set up our logger's.
We'd make sure our session is populated in the opt out session.
We create the template cache, all of these things.
Now, one thing that's missing from this that exists over in May not go is something we set up that
says, listen for mail.
And of course, that function sends things to the mail channel.
Now, when I'm running this test for the handler, I don't actually want to make sure that email goes.
I can do that separately by testing the mail package itself for the testing, the send mail go file
in the main package.
So instead, I need to duplicate this functionality and have it not actually send mail.
So what I'm going to do on the setup test go is about here.
Before I create the template cache, I'm going to set up a mail chain mail channel.
It will be an actual channel and it will be just like we did in the in the main package.
It will make a CHANNE models dot mail data.
So I have that channel and then I'll set my app Milchan to that variable.
I just created that channel I just created, which works great and I will defer the close of that channel.
As I should, and then I'm going to call a function that doesn't exist yet, I don't want to create
that in a moment.
Listen for male.
So this is going to duplicate the functionality that we do in our actual live application, so let's
create that function and I will create it.
I will call it listen for male.
And it's going to do pretty much the same thing that we do in our live application, but I'm going to
skip the actual sending of mail.
OK, so I will say go funk, just like I do in the other one.
Let her get the parentheses right.
And I will put a for loop that runs forever until the application stops running, and inside of that
I will actually handle but do nothing with anything that is sent to the mail channel.
Now, I have a typo here somewhere.
There it is, closing parentheses after that anonymous function.
Now now that I have this set up, I actually do have a means of doing something that I send to the mail
channel.
But I'm going to ignore I'm just going to say, OK, I got something from the male friend, but do nothing
with it.
So let's try running those tests again, clear the screen, go run or go test dashboard in the handler's
folder.
And they all pass, and that's all we have to do, so again, any time you need to, anytime you make
a change to a function or change to your code base, always run your tests, make sure you need that.
You don't need to update them because you usually do need to update them.
And as is the case here, all I need to do is to mark that functionality that exists in the main program.
I just need to make sure that if I'm trying to send something to a channel and listening for the response,
then I'd better actually implement that functionality in my setup Tesco file.
And that's all there is to it.