1
00:00:00,540 --> 00:00:04,420
So how did you make out with the exercise, writing tests for a reform package?

2
00:00:04,440 --> 00:00:09,420
Hopefully you figured it out and hopefully you found the the errors, the couple of errors that I had

3
00:00:09,420 --> 00:00:10,200
hidden in there.

4
00:00:10,260 --> 00:00:11,130
If not, don't worry.

5
00:00:11,130 --> 00:00:12,750
We'll figure that out right now.

6
00:00:13,260 --> 00:00:15,530
So right now, we have two tests.

7
00:00:15,540 --> 00:00:21,230
We have one for the valid function test form valid and one for the required function.

8
00:00:21,240 --> 00:00:26,090
And those, of course, correspond to these the valid and the required.

9
00:00:26,790 --> 00:00:29,040
So those both work.

10
00:00:29,130 --> 00:00:34,280
I can open up a command prompt and make sure I'm in the right directory and I am and just right go test

11
00:00:34,300 --> 00:00:35,500
Dashti and they both pass.

12
00:00:35,820 --> 00:00:36,390
Yes, they do.

13
00:00:37,230 --> 00:00:42,630
So let's write one for the next function and the next function is has and that's a really short function

14
00:00:42,630 --> 00:00:43,830
that should be easy to test.

15
00:00:43,830 --> 00:00:46,110
So let's write a function for a test for it.

16
00:00:46,770 --> 00:00:55,020
Func test form has and in there we need to create a request and we need to create a post form, a form

17
00:00:55,020 --> 00:00:57,780
with that request, which we did right up here in test form required.

18
00:00:57,780 --> 00:01:04,500
So we can do the same thing here and then we need to actually call and test that function so we can

19
00:01:04,500 --> 00:01:11,760
just say has which will be Boolean is assign the value of form it has and then it takes two parameters,

20
00:01:11,760 --> 00:01:13,140
the field, which can be anything.

21
00:01:13,140 --> 00:01:18,420
So whatever one that I know doesn't exist is what I'm going to try right now and we need to pass it

22
00:01:18,420 --> 00:01:18,960
our request.

23
00:01:20,550 --> 00:01:26,730
So when this is called, we're calling it with a request that we made here and then we're posting adding

24
00:01:26,730 --> 00:01:30,960
to the form the post form values from that request, which are currently empty.

25
00:01:31,290 --> 00:01:34,770
And just so you know, we didn't have to create this request necessarily.

26
00:01:34,920 --> 00:01:37,680
Well, we did right now, because we're passing a request to it.

27
00:01:38,550 --> 00:01:39,000
We are.

28
00:01:39,000 --> 00:01:40,130
But that's one of the problems.

29
00:01:40,140 --> 00:01:41,520
Here's one of our hidden errors.

30
00:01:41,520 --> 00:01:42,390
Let's see how this works.

31
00:01:42,390 --> 00:01:43,860
First of all, it's going to seem like it works.

32
00:01:44,460 --> 00:01:47,340
So I call this I'm passing nothing in the post.

33
00:01:47,340 --> 00:01:49,260
So this field should not exist.

34
00:01:49,500 --> 00:01:52,980
Therefore, this should return false because it doesn't have it.

35
00:01:53,370 --> 00:02:02,340
So I just say, if has in other words, if it returns true, then write it er er and the, the message

36
00:02:02,340 --> 00:02:07,970
will be form shows has a field when it does not.

37
00:02:08,520 --> 00:02:13,050
And so far this seems OK, so we'll go run our tests and it will pass.

38
00:02:15,020 --> 00:02:16,670
And it does, and that's correct.

39
00:02:17,180 --> 00:02:24,380
So now let's create another request and check the situation where we know we have posted values in there.

40
00:02:24,380 --> 00:02:25,690
So we already have a request.

41
00:02:25,700 --> 00:02:29,510
I don't need to recreate it, but what I can do is say set up some values.

42
00:02:29,510 --> 00:02:32,600
So I'll say I posted data, which will be a variable.

43
00:02:32,600 --> 00:02:37,600
I create posted data is assigned the value of an empty world values.

44
00:02:38,510 --> 00:02:39,470
So that's the type.

45
00:02:39,470 --> 00:02:45,560
So creates a variable of type YORO values, which is what post form is, and it has nothing in it right

46
00:02:45,560 --> 00:02:45,770
now.

47
00:02:45,780 --> 00:02:46,820
So let's put something in it.

48
00:02:46,820 --> 00:02:52,490
Posted data, don't add and we'll put a key of A and a value of it.

49
00:02:52,490 --> 00:02:57,290
Doesn't matter what it is, as long as I know it's in there, then we need to reinitialize our form

50
00:02:57,860 --> 00:03:03,920
with our new request so we can just say form equals new.

51
00:03:04,910 --> 00:03:15,680
And I could again put a sign this value to the request or as I did, as I did in previous examples up

52
00:03:15,680 --> 00:03:16,640
here, for example.

53
00:03:17,240 --> 00:03:22,080
But I can also just pass in posted posted data itself because that's of the correct type.

54
00:03:23,420 --> 00:03:29,210
So the only reason I created a request here was because when I call it, I have to pass in a request.

55
00:03:29,510 --> 00:03:30,500
Now watch what happens.

56
00:03:30,510 --> 00:03:36,540
I've now added the A parameter with the value of a two hour posted data.

57
00:03:36,890 --> 00:03:45,500
So when I call, here's our second test in this test has is equal to form DOT has and I'll say a and

58
00:03:45,500 --> 00:03:46,220
the request.

59
00:03:46,910 --> 00:03:50,240
What I think I'm doing is passing it the correct information.

60
00:03:50,240 --> 00:03:54,530
Check this request for the existence of a field named A in the post request.

61
00:03:55,110 --> 00:04:00,920
So I should be able to say if it doesn't have it, it has its faults, then write an error together.

62
00:04:02,450 --> 00:04:08,600
We can say shows form does not have field when it should.

63
00:04:08,640 --> 00:04:11,010
Now so far this seems to make perfect sense.

64
00:04:11,420 --> 00:04:13,820
So let's go back and run our test.

65
00:04:14,660 --> 00:04:18,440
Go test Dashty and it fails.

66
00:04:18,440 --> 00:04:21,680
It says shows form does not have field when it should.

67
00:04:21,690 --> 00:04:28,430
So that test we just wrote seems to fail and that appears to make no sense whatsoever because I took

68
00:04:28,430 --> 00:04:32,450
this, I created my my post data, I put the value in there.

69
00:04:32,450 --> 00:04:37,800
It's named a I reinitialize my form variable and past it the post of data.

70
00:04:37,820 --> 00:04:39,210
So this should pass.

71
00:04:39,320 --> 00:04:42,890
So let's go look at the the the function and see what the problem is.

72
00:04:43,580 --> 00:04:52,850
And the problem is right here, when I actually check it's this line in line 42 in my code, I'm saying

73
00:04:52,850 --> 00:04:54,770
go to the request that you passed me.

74
00:04:55,340 --> 00:05:00,860
Look at the form on that request and check for the existence of the field named whatever this is, whatever

75
00:05:00,860 --> 00:05:01,710
the first value is.

76
00:05:01,730 --> 00:05:08,180
So when we call this, I'm passing in my test, I'm passing it a here and I'm passing that request we

77
00:05:08,180 --> 00:05:10,820
manually created right in our test.

78
00:05:10,910 --> 00:05:12,590
That's the request I'm checking.

79
00:05:13,160 --> 00:05:16,700
What we should be checking is this one in the receiver.

80
00:05:16,730 --> 00:05:19,490
That's why we have this line right here.

81
00:05:19,490 --> 00:05:21,620
Form equals new posted data.

82
00:05:22,010 --> 00:05:26,450
When I call form, I'm actually looking at the request associated with the form.

83
00:05:26,450 --> 00:05:29,690
And this is not only unnecessary, we're not doing anything with it.

84
00:05:29,690 --> 00:05:32,440
And in fact, we can and will eventually get rid of it.

85
00:05:33,080 --> 00:05:40,580
So to make this test work properly, what I need to do is fix this line and not check on our short form

86
00:05:40,580 --> 00:05:41,020
instead.

87
00:05:41,100 --> 00:05:45,020
Instead, I should be checking f the value from our receiver.

88
00:05:45,020 --> 00:05:45,770
Check that.

89
00:05:45,770 --> 00:05:47,600
And now this isn't even being used.

90
00:05:47,600 --> 00:05:51,650
I'm not going to delete it right now, but I will a little bit later on when we actually run the application

91
00:05:51,650 --> 00:05:54,350
because now it's totally unnecessary request.

92
00:05:55,100 --> 00:06:01,010
So I can go back now, now that I fixed this line, go back to my command prompt and run the test again.

93
00:06:01,880 --> 00:06:05,510
And it passes, and that is one of the hidden errors.

94
00:06:05,930 --> 00:06:07,920
So that's the test for his function.

95
00:06:08,120 --> 00:06:09,090
What's our next function?

96
00:06:09,140 --> 00:06:10,470
Let's go back here and have a look.

97
00:06:10,850 --> 00:06:12,400
The next one is min length.

98
00:06:12,410 --> 00:06:20,660
So let's check that one will create a test for min length func test form min length.

99
00:06:21,930 --> 00:06:23,360
And what do we want to do here?

100
00:06:23,390 --> 00:06:29,360
Well, if we look at the function again, min length appears to take this first parameter, which is

101
00:06:29,360 --> 00:06:30,560
our field, then we're checking.

102
00:06:30,890 --> 00:06:34,270
The second one is an ant and the third one is the request.

103
00:06:34,490 --> 00:06:37,870
And as you can see, here's our second error right away.

104
00:06:37,880 --> 00:06:43,400
I know one because I just fixed it up here that this is checking the wrong parameter is checking the

105
00:06:43,400 --> 00:06:49,010
are the request from here when it should be checking the request that's actually associated with our

106
00:06:49,010 --> 00:06:49,600
receiver.

107
00:06:49,610 --> 00:06:50,780
So I'll just copy this.

108
00:06:53,350 --> 00:07:00,250
And replace this and again, that means this parameter is no longer required and there's no point in

109
00:07:00,250 --> 00:07:03,130
having parameters and functions that we never, ever use.

110
00:07:03,220 --> 00:07:04,810
So we'll get rid of that in a bit.

111
00:07:05,200 --> 00:07:10,650
First of all, let's get the test passing so we can use exactly the same logic.

112
00:07:10,780 --> 00:07:12,760
And now that I know I don't need a request.

113
00:07:12,770 --> 00:07:13,840
Well, actually, at the moment I do.

114
00:07:13,840 --> 00:07:17,110
So I'll create a request here, but we'll get rid of that momentarily.

115
00:07:17,320 --> 00:07:20,340
OK, we're just building a request we're not even going to use.

116
00:07:20,830 --> 00:07:27,550
I can create a new form using this request we just built and we will write our first test.

117
00:07:27,730 --> 00:07:34,040
And our first test is we'll make sure that min length doesn't work for a nonexistent field.

118
00:07:34,060 --> 00:07:34,490
OK.

119
00:07:34,510 --> 00:07:39,160
So in other words, I'm going to just do a really simple thing form mind length.

120
00:07:39,160 --> 00:07:42,490
I'll call that and I'll call it with a field I know does not exist.

121
00:07:42,490 --> 00:07:47,560
And no fields exist in the post data right now and give it some length and then the request and will

122
00:07:47,560 --> 00:07:50,300
write the test if form valid.

123
00:07:51,010 --> 00:07:54,510
In other words, this should be set to fault's right now.

124
00:07:54,550 --> 00:07:59,800
I know that the form, the form valid should return false because it's checking the length of a non-existent

125
00:07:59,800 --> 00:08:00,310
field.

126
00:08:00,790 --> 00:08:02,110
Then I need to throw an error.

127
00:08:02,980 --> 00:08:15,790
Teda error shows a min length, let's say form shows, form shows in length for non existent field.

128
00:08:18,010 --> 00:08:20,740
OK, so let's run that test, see what happens.

129
00:08:23,640 --> 00:08:30,120
And it passed, so this time will create a post values again, just like we did above posted values

130
00:08:30,120 --> 00:08:35,580
is assigned an empty URL values, and then we'll add a feel to it.

131
00:08:35,850 --> 00:08:46,260
So we'll say posted posted values, dot ad and we'll call our field some field and we'll give it a value

132
00:08:46,260 --> 00:08:47,840
of some value.

133
00:08:48,360 --> 00:08:52,920
So that is one, two, three, four, five, six, seven, eight, nine, 10 characters long.

134
00:08:52,980 --> 00:08:59,820
OK, so now we can read our test so we can just easily say form equals new

135
00:09:02,790 --> 00:09:06,200
and it'll be posted values.

136
00:09:08,040 --> 00:09:13,530
So that creates a new form and it passes it this information for the for the form values.

137
00:09:13,530 --> 00:09:18,580
So it passes in one parameter with the name of some field and the value of some value.

138
00:09:18,600 --> 00:09:21,050
And now we have a form that has some data we can test.

139
00:09:21,510 --> 00:09:30,810
So let's test it and we'll say form dot min length and the field name is Summer Field.

140
00:09:31,530 --> 00:09:32,880
The length will put it 100.

141
00:09:32,880 --> 00:09:36,780
So we know that it's going to not going to be long enough and we'll pass in that request that we're

142
00:09:36,780 --> 00:09:39,570
not doing anything with which we'll have to get rid of eventually.

143
00:09:39,990 --> 00:09:49,650
And we can just say, if formed valid, if this is if it shows the form is valid, that fails the test

144
00:09:49,650 --> 00:09:53,000
because we know that some value is less than one hundred characters long.

145
00:09:53,010 --> 00:10:03,870
So we'll say to air shows, min length of one hundred met when data is shorter.

146
00:10:05,070 --> 00:10:08,400
All right, let's test that go test dash.

147
00:10:10,330 --> 00:10:16,090
And it passes, so now we need to test the other case, create posted values, posted values we're not

148
00:10:16,090 --> 00:10:16,490
going to create.

149
00:10:16,510 --> 00:10:18,340
We're going to reinitialize posted.

150
00:10:18,340 --> 00:10:21,570
Values is equal to your values.

151
00:10:22,540 --> 00:10:22,930
All right.

152
00:10:22,930 --> 00:10:27,730
So that reinitialize are posted values to be empty and then we'll add a value to it.

153
00:10:28,060 --> 00:10:37,120
Posted values don't add and we'll call this one another field and we'll give it the length of ABC.

154
00:10:37,510 --> 00:10:39,610
One, two, three, something greater than one.

155
00:10:39,610 --> 00:10:41,160
We'll just test for a minute length of one.

156
00:10:42,280 --> 00:10:43,990
Now we have to reinitialize our form.

157
00:10:43,990 --> 00:10:47,320
Form equals new and we'll pass in our posted values.

158
00:10:48,670 --> 00:10:50,590
And now we call them in length form.

159
00:10:50,920 --> 00:10:51,430
In length.

160
00:10:51,970 --> 00:10:56,850
And our field is another field arm in length will be one.

161
00:10:57,220 --> 00:11:01,690
So we know what we're passing in is longer than one character and we'll pass at that request, which

162
00:11:01,690 --> 00:11:02,920
we're not actually using at the moment.

163
00:11:03,160 --> 00:11:04,610
But we'll take care of that shortly.

164
00:11:05,530 --> 00:11:08,560
And now this should pass validation.

165
00:11:08,560 --> 00:11:10,180
So we we need to test that.

166
00:11:10,180 --> 00:11:22,750
If it doesn't pass validation, if not form valid and fail the test teda error shows min length of one

167
00:11:23,620 --> 00:11:26,050
is not met when it is.

168
00:11:26,470 --> 00:11:29,560
All right, let's go back and run our tests.

169
00:11:32,120 --> 00:11:33,860
So go test Dashti.

170
00:11:35,440 --> 00:11:37,510
And everything passes perfect.

171
00:11:37,930 --> 00:11:40,540
All right, so, so far, so good.

172
00:11:40,720 --> 00:11:44,000
Do we have anything left to test is email.

173
00:11:44,290 --> 00:11:45,310
That's our last one.

174
00:11:45,430 --> 00:11:48,970
Well, that one should be pretty easy to let's write that test.

175
00:11:49,390 --> 00:11:50,560
So we'll write a new function.

176
00:11:51,130 --> 00:11:57,940
Funk test form is email.

177
00:11:59,110 --> 00:12:03,970
And we need to as we generate along, we'll create a formal request and our form

178
00:12:06,910 --> 00:12:09,540
and we will look at these email functions.

179
00:12:09,550 --> 00:12:10,480
So what does that require?

180
00:12:10,510 --> 00:12:13,280
That requires just a field name.

181
00:12:13,330 --> 00:12:14,080
That's easy enough.

182
00:12:14,440 --> 00:12:18,370
He formed out is email with a nonexistent field.

183
00:12:18,550 --> 00:12:19,570
X doesn't exist.

184
00:12:20,020 --> 00:12:21,940
And then we just check to see if the form is valid.

185
00:12:21,940 --> 00:12:26,410
If formed valid t don't.

186
00:12:26,880 --> 00:12:32,650
It can't be valid because we passed it no value whatsoever and the error should just say something like

187
00:12:32,650 --> 00:12:38,710
form shows valid email for non existent field.

188
00:12:39,610 --> 00:12:41,350
OK, so let's run that test.

189
00:12:43,490 --> 00:12:45,840
Go test Dashti, perfect.

190
00:12:46,580 --> 00:12:51,050
So now let's try passing at a valid email, so we'll just again, as we've done right along, posted

191
00:12:51,050 --> 00:12:55,900
values will create that variable is a sign the value of an empty.

192
00:12:55,900 --> 00:12:58,780
You are Elgort values and then we'll add a value to it.

193
00:12:59,510 --> 00:13:05,590
The posted values dot ad and we'll call it email and we'll give it a valid email address.

194
00:13:05,630 --> 00:13:09,860
So a valid email address could be something as simple as me here.

195
00:13:09,860 --> 00:13:10,490
Dot com.

196
00:13:11,450 --> 00:13:13,730
OK, and we need to reinitialize our form.

197
00:13:13,740 --> 00:13:22,470
So form equals new and we'll just put in our post-it values and then finally we'll call it the test

198
00:13:22,470 --> 00:13:30,440
together form DOT is email and the value of where we want to check is email.

199
00:13:31,400 --> 00:13:32,470
And that's all we have to do.

200
00:13:33,470 --> 00:13:35,000
And then we check to see if we get it.

201
00:13:35,010 --> 00:13:41,480
Now, we should be getting a valid form now, right, because we passed it a field named email with

202
00:13:41,480 --> 00:13:43,570
something that's in the form of an email address.

203
00:13:43,610 --> 00:13:50,390
So we need to check if the form is not valid, if not form valid t dot error.

204
00:13:52,160 --> 00:13:53,330
And the error would be.

205
00:13:55,590 --> 00:14:02,100
Got an invalid email when we should not have.

206
00:14:02,370 --> 00:14:05,460
All right, let's run that test for the screen.

207
00:14:05,970 --> 00:14:08,420
Run the test and it passes.

208
00:14:08,640 --> 00:14:09,140
Perfect.

209
00:14:09,630 --> 00:14:10,150
All right.

210
00:14:10,350 --> 00:14:12,150
Anything else we should be testing here?

211
00:14:12,340 --> 00:14:15,630
We should be testing, passing an invalid email address.

212
00:14:15,750 --> 00:14:21,360
And what we can do is just copy this entire section pasted here and modify it.

213
00:14:21,780 --> 00:14:29,430
So posted values is now equal to your values and posts and values will add an email that will just put

214
00:14:29,430 --> 00:14:31,800
X in there, which we know is not an email address.

215
00:14:32,490 --> 00:14:34,440
And then we reinitialize our form.

216
00:14:34,440 --> 00:14:40,830
We check it for the field named email, which currently has the value of X, and if the form is valid

217
00:14:40,830 --> 00:14:50,790
this time, that got valid for invalid email address and I can just delete the rest of this.

218
00:14:51,790 --> 00:14:54,020
And that should work.

219
00:14:55,120 --> 00:14:56,740
So let's run our tests.

220
00:14:58,040 --> 00:14:59,550
And everything passed good.

221
00:15:00,290 --> 00:15:04,600
Now there's a couple of things we can do here that actually will make this a little bit cleaner.

222
00:15:05,270 --> 00:15:07,850
So we've passed all of our tests and we'll check our coverage in a minute.

223
00:15:07,850 --> 00:15:10,850
But right away, we don't need this request.

224
00:15:11,280 --> 00:15:13,810
This this creating this request is utterly useless.

225
00:15:13,820 --> 00:15:16,610
All we need to do is to create a universal values.

226
00:15:16,640 --> 00:15:25,010
So what I'm going to do is copy this and replace this line with that and then change this to an equals,

227
00:15:25,010 --> 00:15:25,970
not in the sign.

228
00:15:26,480 --> 00:15:32,810
And up here, I'll just pass in posted values, because really, when you think about it, this new

229
00:15:32,810 --> 00:15:35,470
function requires you are values.

230
00:15:35,510 --> 00:15:36,390
That's what it requires.

231
00:15:36,410 --> 00:15:37,580
It doesn't require a request.

232
00:15:37,600 --> 00:15:41,630
So we were creating request for no point whatsoever.

233
00:15:41,780 --> 00:15:47,480
Now, up here, when we thought things were working properly with the highs, we were creating a request

234
00:15:47,480 --> 00:15:47,910
as well.

235
00:15:48,170 --> 00:15:52,780
So what we were doing that because we thought we had to pass request as a parameter.

236
00:15:52,820 --> 00:15:54,080
So let's fix that right now.

237
00:15:54,470 --> 00:15:59,630
Let's get rid of the request for the has this parameter in the house function.

238
00:16:00,260 --> 00:16:03,710
So that is gone and we'll go back to forms test.

239
00:16:04,220 --> 00:16:07,910
We don't need this request anymore and we don't need this request anymore.

240
00:16:08,600 --> 00:16:11,990
And now we should be able to run those tests and still have them pass.

241
00:16:13,380 --> 00:16:15,760
Go test, so it'll all work just fine.

242
00:16:15,780 --> 00:16:23,400
Great in the same way, when we call min length, we don't need that requestor anymore, so let's get

243
00:16:23,400 --> 00:16:26,330
rid of that and get rid of it right here.

244
00:16:27,750 --> 00:16:29,520
And I think that's it for that one.

245
00:16:29,520 --> 00:16:35,210
So we can go back here and remove this parameter, which is pointless and serves no purpose whatsoever

246
00:16:36,240 --> 00:16:38,350
and see if we have everything working up.

247
00:16:38,370 --> 00:16:40,280
One more down here, get rid of that one.

248
00:16:41,190 --> 00:16:43,130
So we should be able to pass those tests again.

249
00:16:44,610 --> 00:16:45,430
And we do.

250
00:16:45,480 --> 00:16:46,200
That's great.

251
00:16:46,950 --> 00:16:54,840
OK, now the last thing I need to check before I can actually say that this part is done is to make

252
00:16:54,840 --> 00:16:58,570
sure now that I've changed that function, does our program still compile?

253
00:16:58,590 --> 00:17:05,010
So I'll go back to my terminal window, clear the screen, I shall open a new tab just so I don't have

254
00:17:05,010 --> 00:17:12,460
to find this folder again and go to my Gulland projects and my bookings and I will run this.

255
00:17:12,480 --> 00:17:17,550
So remember, running this now isn't as easy as going go run command

256
00:17:20,160 --> 00:17:21,930
web Stargirl.

257
00:17:21,990 --> 00:17:24,020
That'll fail because there's test files in there.

258
00:17:24,150 --> 00:17:29,220
So we actually have to specify the three, the three files that are in there that are not test files

259
00:17:29,670 --> 00:17:33,570
may not go and command web rootstock.

260
00:17:33,570 --> 00:17:44,010
Go and command Web middleware Dudko and hopefully it'll run and it fails and it fails at handlers go

261
00:17:44,010 --> 00:17:45,030
line Eighty-seven.

262
00:17:45,030 --> 00:17:46,110
And that's why I'm checking this.

263
00:17:46,110 --> 00:17:47,220
So let's go fix that right now.

264
00:17:47,220 --> 00:17:53,160
Handlers go line eighty seven right here, so let's get rid of that.

265
00:17:53,160 --> 00:17:57,210
We no longer want the request in there and now we'll try running the program again.

266
00:17:57,540 --> 00:17:59,790
So I'll just hit the up arrow to get the command back.

267
00:18:01,770 --> 00:18:07,290
And it runs all right, so now I'm going to go back to my other terminal window, which is in the correct

268
00:18:07,290 --> 00:18:07,810
directory.

269
00:18:08,100 --> 00:18:14,870
Let's check our coverage on this and see if we have everything we want covered in the forms package,

270
00:18:14,910 --> 00:18:16,710
go test, dash cover.

271
00:18:18,400 --> 00:18:20,320
And it says eighty one point eight percent.

272
00:18:20,430 --> 00:18:21,690
I thought I tested everything.

273
00:18:21,850 --> 00:18:24,120
Well, let's find out what we didn't test.

274
00:18:24,390 --> 00:18:31,410
So I'm going to use my shorthand coverage, my little alias, and you might have to type the command

275
00:18:31,410 --> 00:18:32,480
all the way out there.

276
00:18:32,490 --> 00:18:33,540
Let's see what we have here.

277
00:18:33,540 --> 00:18:33,960
So right.

278
00:18:33,960 --> 00:18:34,920
Inform start go.

279
00:18:34,920 --> 00:18:37,980
At no point did I try the get function.

280
00:18:37,980 --> 00:18:39,020
Well, I'm going to have to do that.

281
00:18:39,030 --> 00:18:40,080
That should be pretty easy.

282
00:18:40,590 --> 00:18:44,310
But the other one has 100 percent coverage, which is perfect.

283
00:18:44,490 --> 00:18:44,960
All right.

284
00:18:45,180 --> 00:18:47,640
So how do I check the jet function?

285
00:18:47,670 --> 00:18:48,610
Well, it's really easy.

286
00:18:48,630 --> 00:18:54,000
It's what I'm going to do is close this and go back to my tests under form tests.

287
00:18:54,330 --> 00:18:58,620
And right here, when I say, for example, I just need to check it in one spot and then I know that

288
00:18:58,620 --> 00:18:59,070
it works.

289
00:18:59,490 --> 00:19:03,960
So we need to find somewhere where I can call the jet function and get no error.

290
00:19:04,470 --> 00:19:09,440
And then I need to find somewhere where I can call the jet function and get an error.

291
00:19:10,140 --> 00:19:18,060
So how am I going to do this right away if this one if it shows the form is valid, if this test fails?

292
00:19:18,060 --> 00:19:20,640
Well, after that, I know that there should be an error in there.

293
00:19:20,640 --> 00:19:23,280
So I can just say and I'll just store the values.

294
00:19:23,280 --> 00:19:25,470
So I'll call it X.

295
00:19:25,470 --> 00:19:35,010
No, I'll call it is error is assign the value of form errors get and then the field name I used up

296
00:19:35,010 --> 00:19:41,730
here, which is X, and then I just need to make sure that there is no or that there is an error.

297
00:19:42,090 --> 00:19:48,180
So I'll say if X is equal to nothing because in the jet function, which is right over in our errors

298
00:19:48,180 --> 00:19:55,290
file, I believe right here in the jet function, it returns an empty string if there is no error,

299
00:19:55,320 --> 00:19:56,910
otherwise it returns the error.

300
00:19:56,910 --> 00:19:59,250
And I need to check both of these conditions.

301
00:19:59,500 --> 00:20:04,860
So when the first case where I'm expecting an error to be there, so if these are not yet these air

302
00:20:05,070 --> 00:20:08,880
X if is error is an empty string, that didn't work.

303
00:20:08,880 --> 00:20:19,080
So I need to throw an error, pilot error and I should just say something like should have an error

304
00:20:19,950 --> 00:20:21,990
but did not get one.

305
00:20:22,270 --> 00:20:24,990
OK, and now I need to use the same logic.

306
00:20:24,990 --> 00:20:28,620
So I'll just copy this when there is no error.

307
00:20:28,770 --> 00:20:34,680
OK, so when do I know there is no error if the form is valid.

308
00:20:35,490 --> 00:20:36,450
Is this the case now?

309
00:20:36,450 --> 00:20:37,230
I'm not going to say so.

310
00:20:37,410 --> 00:20:43,530
It shows mean like the 101 data is shorter, so I need to check when there is no error and oh here we

311
00:20:43,530 --> 00:20:43,670
are.

312
00:20:43,950 --> 00:20:45,900
So if the form is not valid.

313
00:20:45,900 --> 00:20:51,060
So after this test, when I'm passing it another field and checking for a length of one, I know this

314
00:20:51,060 --> 00:20:52,050
test should pass.

315
00:20:52,050 --> 00:20:53,820
Therefore there should be no error.

316
00:20:54,090 --> 00:20:59,670
So I can just paste what I had there, change this to an equals because I can't reinitialize or redeclared

317
00:20:59,670 --> 00:21:01,440
the variable twice in the same block.

318
00:21:02,040 --> 00:21:07,280
And I'm going to look for the field not called X, but the field called another field.

319
00:21:07,860 --> 00:21:16,650
So and now I say if error is equal to nothing, if error is not equal to nothing, should not have an

320
00:21:16,650 --> 00:21:18,930
error but got one

321
00:21:22,290 --> 00:21:23,310
and that should do it.

322
00:21:24,090 --> 00:21:25,380
So let's just look at this again.

323
00:21:25,860 --> 00:21:30,780
In the first case up here, I'm calling with an empty post for him.

324
00:21:30,780 --> 00:21:32,400
There's nothing in there whatsoever.

325
00:21:32,430 --> 00:21:34,410
So I know there should be an error.

326
00:21:34,560 --> 00:21:40,980
And I check to say if there's no error for the field X, then write an error.

327
00:21:40,980 --> 00:21:47,520
Fail the test down here when I know I'm calling a valid request and my form should be valid.

328
00:21:48,090 --> 00:21:50,280
This what I call form errors.

329
00:21:50,280 --> 00:21:55,470
Get on another field, which is the field I just tested right here, then I should have an error.

330
00:21:55,920 --> 00:21:58,050
So if so, I should not have an error.

331
00:21:58,050 --> 00:22:04,410
So I say if error is not equal to an empty string, then I write, fail my test and write the appropriate

332
00:22:04,410 --> 00:22:05,030
error message.

333
00:22:05,030 --> 00:22:10,380
So let's test this, go back to our web browser and run our test.

334
00:22:12,430 --> 00:22:13,290
Everything passed.

335
00:22:13,330 --> 00:22:14,380
Now let's check our coverage.

336
00:22:18,510 --> 00:22:23,820
I have 100 percent coverage for errors Torgau and I have 100 percent coverage for Forms Dutko, and

337
00:22:23,820 --> 00:22:26,370
that is exactly what I wanted.

338
00:22:26,910 --> 00:22:27,410
All right.

339
00:22:27,450 --> 00:22:31,560
That is the last bit we need to do for this particular package.

340
00:22:31,770 --> 00:22:33,020
So let's move on.
