1 00:00:01,140 --> 00:00:03,690 The next day we're going to do is fix up a couple of tests. 2 00:00:03,700 --> 00:00:07,030 Now these are specifically tests around our different root handlers. 3 00:00:07,060 --> 00:00:08,440 Let's go back over to a terminal. 4 00:00:08,470 --> 00:00:10,110 We're going to take another look at our test suite. 5 00:00:10,110 --> 00:00:14,670 We're gonna run all the tests instead of what order service and we will see that a couple are failing. 6 00:00:14,680 --> 00:00:16,360 OK so back to my terminal. 7 00:00:16,450 --> 00:00:18,540 Here's my test suite inside the order service. 8 00:00:18,640 --> 00:00:23,420 We are currently filtered and only running tests with the name listener inside the TEST file name. 9 00:00:23,460 --> 00:00:26,100 So I want to undo that filter by pressing W.. 10 00:00:26,320 --> 00:00:32,450 And then a to run all tests so we're gonna see that these tests around are different route handlers 11 00:00:32,450 --> 00:00:35,570 are going to fail pretty catastrophically. 12 00:00:35,570 --> 00:00:39,410 And if we take a look at each of these you'll notice as I mentioned last video is because we are building 13 00:00:39,410 --> 00:00:44,690 tickets without providing an I.D. at some point time when we are working all the on all these listeners 14 00:00:44,690 --> 00:00:48,980 and all these events we said that we needed to make sure that we had consistent ideas being used between 15 00:00:48,980 --> 00:00:50,890 the ticket service and the order service. 16 00:00:50,930 --> 00:00:57,320 So we had required that whenever we called Ticket Talk Build we had to provide an I.D. property inside 17 00:00:57,320 --> 00:00:57,800 of our test. 18 00:00:57,800 --> 00:01:01,610 We still have some code where we are creating tickets without providing an I.D.. 19 00:01:01,730 --> 00:01:06,350 So we really have to do is go around to a different route handle our test files whenever we build a 20 00:01:06,410 --> 00:01:07,030 ticket. 21 00:01:07,040 --> 00:01:15,290 We have to include a randomly generated I.D. that's pretty much it so inside my order service I'm going 22 00:01:15,290 --> 00:01:21,970 to find our roots directory I'm going gonna find the test folder inside there and I'll open up delete 23 00:01:22,030 --> 00:01:22,470 test. 24 00:01:22,590 --> 00:01:28,950 Yes so inside of you right away we're going to see some errors around building a ticket right here and 25 00:01:28,980 --> 00:01:31,720 right here in both cases. 26 00:01:31,730 --> 00:01:37,560 Oh you have to do is use Mongoose to generate a brand new random I.D. and assign it to the ticket dot 27 00:01:37,560 --> 00:01:39,440 built that's it. 28 00:01:39,450 --> 00:01:47,050 So at the very top we will import Mongoose from Mongoose then inside the build method allowed in an 29 00:01:47,050 --> 00:01:57,540 I.D. which will be Mongoose that types dot object I.D. not to hex bring like so. 30 00:01:57,750 --> 00:02:02,000 Now we're going to have to duplicate this line right here into pretty much all for these test files. 31 00:02:02,020 --> 00:02:08,820 So I'm going to copy this line and we're going to go round to these four files and paste that line everywhere 32 00:02:08,820 --> 00:02:15,140 that we build a ticket the first are going to scroll down a little bit lower in this file find the next 33 00:02:15,140 --> 00:02:20,700 air and I'll paste in the 80 like so and that is it for the delete test file. 34 00:02:20,740 --> 00:02:21,790 Fix it up. 35 00:02:21,850 --> 00:02:28,390 So going to say this and close it Next up I'll move on to the next test file of index test. 36 00:02:28,430 --> 00:02:37,580 Yes at the very top I will import Mongoose from mongoose. 37 00:02:37,580 --> 00:02:39,370 And then once again paste in that 80 38 00:02:42,200 --> 00:02:47,650 that is it for this file so I'll save it and close it onto the new test file. 39 00:02:47,870 --> 00:02:52,460 We've already imported Mongoose at the top so we can scroll through here find every location where we 40 00:02:52,460 --> 00:02:55,080 build a ticket and paste in that idea line. 41 00:02:55,100 --> 00:02:56,480 There's one right there 42 00:03:00,290 --> 00:03:00,920 ears to 43 00:03:04,070 --> 00:03:05,390 and here's three. 44 00:03:05,600 --> 00:03:11,420 So three locations in this file were we where we are going to paste in the idea thing that is it for 45 00:03:11,420 --> 00:03:12,370 the new test file. 46 00:03:12,410 --> 00:03:13,450 So close that one. 47 00:03:13,490 --> 00:03:15,280 And then finally onto a show test. 48 00:03:15,370 --> 00:03:16,230 Yes. 49 00:03:16,550 --> 00:03:18,500 Once again at the very top I will import Mongoose 50 00:03:21,380 --> 00:03:25,450 and then I will paste in the idea there's one right there. 51 00:03:25,450 --> 00:03:29,270 One more error little bit down right here pasted in. 52 00:03:29,410 --> 00:03:31,120 Let's two inside the show test. 53 00:03:31,120 --> 00:03:33,000 Yes file it. 54 00:03:33,030 --> 00:03:39,980 Let's say this was the file down and then go back over to our terminal and see how our tests are doing. 55 00:03:40,000 --> 00:03:44,770 It looks like we still have a couple of failures but these are failures related to our root handlers. 56 00:03:44,770 --> 00:03:49,660 As I mentioned we went through our different events inside the common module just a little bit ago and 57 00:03:49,660 --> 00:03:54,310 we said that all of our different events had to include a version property inside of our different root 58 00:03:54,310 --> 00:03:54,730 handlers. 59 00:03:54,730 --> 00:04:00,160 Right now we have several locations where we are publishing events but we are not including any version 60 00:04:00,160 --> 00:04:00,760 property. 61 00:04:00,910 --> 00:04:03,340 And so that's what we're seeing from the delete Roc handler. 62 00:04:03,340 --> 00:04:08,350 Right now we are getting an error from typescript that distinctly says hey you have to include a version 63 00:04:08,350 --> 00:04:13,220 property whenever you are trying to publish a order it canceled events. 64 00:04:13,360 --> 00:04:14,050 That's pretty much it. 65 00:04:14,050 --> 00:04:18,580 We just have to go round to two different root handlers and make sure that we include that version property 66 00:04:19,730 --> 00:04:21,450 let's take care of that right now. 67 00:04:21,580 --> 00:04:22,560 Does other routes rectory. 68 00:04:22,570 --> 00:04:23,310 I'll find delete. 69 00:04:23,450 --> 00:04:30,930 Yes but here's the delete root handler is the one it's going to cancel in order there is a we published 70 00:04:30,930 --> 00:04:32,880 an event and if you mouse over this. 71 00:04:32,900 --> 00:04:37,610 Yep it pretty much says we have to include a version as we said that we would anytime we publish this 72 00:04:37,610 --> 00:04:38,770 event. 73 00:04:38,780 --> 00:04:44,840 The version is going to come off the order that we are canceling so remember the entire idea here is 74 00:04:44,840 --> 00:04:48,860 that a lot of our different records are going to include these version flags as the primary means of 75 00:04:48,860 --> 00:04:52,400 concurrency control that's what's going to make sure that we process all these different events in the 76 00:04:52,400 --> 00:04:53,540 correct order. 77 00:04:53,550 --> 00:04:58,280 So there's some other service out there that's going to eventually listen to the order canceled events. 78 00:04:58,280 --> 00:05:03,290 It's going to use the version field of this order to make sure that the event gets processed in the 79 00:05:03,290 --> 00:05:07,240 correct order they're going to take this order that we just canceled. 80 00:05:07,240 --> 00:05:10,870 We're gonna take its version property and just include it inside the event. 81 00:05:10,990 --> 00:05:14,470 We'll throw in version is going to be order DOD version. 82 00:05:14,470 --> 00:05:21,560 Like so there's one other event that we are currently publishing that's inside of the root handler of 83 00:05:21,590 --> 00:05:26,060 new t s so this is where we create a new order. 84 00:05:26,420 --> 00:05:29,970 And if we scroll down a little bit we can see where we are publishing that event. 85 00:05:30,020 --> 00:05:34,890 Here it is right here we're publishing the event and once again we're just not including in the version 86 00:05:34,950 --> 00:05:45,880 when we said we would do so we'll throw in version is order dot version and that's it. 87 00:05:45,950 --> 00:05:50,210 So let's save this at this point time all of our tests should now be working. 88 00:05:50,210 --> 00:05:54,530 So I have to go back over to my terminal and I should see that all the tests inside my order service 89 00:05:54,590 --> 00:05:55,820 are up and running. 90 00:05:55,820 --> 00:05:57,900 Fantastic OK. 91 00:05:57,930 --> 00:06:02,700 So as I mentioned this is just kind of going around and fixing a couple of odds and ends and I just 92 00:06:02,700 --> 00:06:05,820 want to make sure that the goal of all this stuff was really crystal clear. 93 00:06:05,820 --> 00:06:07,910 So at this point we're in a pretty good state. 94 00:06:07,920 --> 00:06:14,400 I would say that our order service is reasonably processing incoming events related to tickets so we're 95 00:06:14,400 --> 00:06:17,420 not going to start to move back over to our tickets service. 96 00:06:17,490 --> 00:06:21,810 We're going to start to investigate some other issues between the ticket service and the order service 97 00:06:22,020 --> 00:06:26,730 specifically around making sure that we actually reserve tickets properly and while a ticket is reserved 98 00:06:26,940 --> 00:06:31,230 we need to also make sure that a user cannot edit 8 tickets title or price. 99 00:06:31,380 --> 00:06:33,570 So a couple more kind of business rule things. 100 00:06:33,600 --> 00:06:35,550 Let's start to tackle this stuff in the next video.