TOA Part 5: Creating A Repository Layer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
yeah i think it's a great discussion i think we we learned a lot and talked about a lot of idea of ideas um so let's now we can talk about the repository version of this let's do that um let's make a new branch here login repository okay so i'm going to throw that inside um we're gonna make a new package inside domain called repository strictly because that's what i saw in the set blog post we were looking at earlier we would call this a login repository because the repository is separate from the use case uh why new branch because um i have no idea if anyone actually looks at these pull requests but i want to be able to have them as clear and separated pull requests um so that if people look at the stream history they could like zone in on a particular topic i should have i should have just gone with the cat that you know and ignored it and we are we are but i would i will take being trolled any day because for every trolley question is someone not talking in chat who actually has that question so i will answer all of them cool i'm glad so that's one reason we do it so and then so our login repository is another layer so our use case is just like hey we need to do this thing but our repository is going to have a little more logic about how we actually log in and the return type of this function will be different i think and here's where it's going to be different so we're going to have a function here it's not going to be an overload we're going to have a function called login which will take an email um and a password also i wonder if i should change where email and password are defined um like i wonder if inside models we should make a class called or a file called credentials or something and then let's take these out because they're not needed here and let's throw them inside here and actually let's go a step further i'm gonna i said i wasn't gonna do it and now i wanna do it we're gonna make its own thing credentials because then it just is cleaner elsewhere we don't have to have email and password all the time right we could have um this will just take in credentials um this screws up all sorts oh we didn't actually use login type i should have deleted that on the last pr whoops um okay login repository so then we can have the login with credentials i'm going to call this login with credentials because i can already see without even looking at it that someone in chat is going to point that out and here is where our result class will actually come in is i want to return a result of a login did i get rid of login response it did and i shouldn't have um let's add it back we want a login response which is actually a response from any request to login to an external service and this is where we're going to get our off token so this is what our login repository does this is the data layer for any requests related to logging in the user yeah i suppose um we could just call it log in but i'm just thinking ahead of like you know if we have like login with google um you know that would be like a different function but let's not get ahead of ourselves because i think that's been one of the struggles of this stream as we keep getting ahead of ourselves can you overload um i thought that i had issues with that or i guess as long as they're different types it's fine yeah as long as the different types if you use the same parameters it will yell at you uh which i've seen i don't know why you would do that but i think i tried to do it once that it yelled at me i have given some user credentials try to log in the user and if successful or a result that contains the login response if successful or an error otherwise also another thing cp said way back then uh hell yeah go blue um i'm currently in new york city but i'm a born and raised michigander so uh i'm actually going to go back to another thing cp mentioned about our results or whoops ah see i knew this was going to come to bite me i knew this was going to come to bite me where's my login repository i'm losing everything i want this to be my result class um oh okay i do actually have i changed a whole bunch of stuff this is a throwable i wanted to make sure that was the throwable that parameter there okay we've got our login repository it's got a way of logging in with credentials so now what we can do is actually um well we're going to need to rename this i don't know why this didn't reality um let's now that we have a repository which this will be the wrapper for like our network request to actually log in the user somewhere now we could actually make our production login our production login use case um so last chance for chat to vote maybe i should have made a poll can i run a poll from here easily i don't actually know how to do anything in my twitch thing yeah i don't know how to start a poll i was going to create a poll on what do we want to call the implementation do we do credentials login use case impul or do we want to oh congratulations it's very exciting um or do we want to call like prod credentials long in the use case um delegated to a mod uh i should be able to do it from the dashboard here i have no idea why it doesn't stand out as like a quick and easy thing for me to do but it's probably because i just don't know how to do anything but we could just vote in chat do we want the impulse suffix or the prod prefix or something else i don't think we want something else um because i don't have anything more specific to call it but i'm leaning towards prawn and so i might just make the executive decision prefix nice all right two votes y'all oh my god chad is finally agreeing with me it's the first time all night i'm so glad all right so one thing is this is going to need to consume a repository and so we can say this is a concrete implementation of a credentials login use case that will request logging in via the login repository and now um now i'm going to throw a curve ball that none of you expected this is our first class that we've defined that is like not just an interface and something we're actually going to be using inside the app so you know what this means it's an opportunity for test driven development so i am not going to implement this invoke function i am going to write tests for a um success and a failure login login scenario and make sure that this class returns the right result yeah tv is really nice so let's dive in let's create the test class um so unit4 throw this in oh thank you for the subscription jimmy i i didn't know that tdd was all i had to do to get subs but we'll do plenty more of it um let's start well one thing is we're going to need a fake login repository um so let's uh let's make one of those so i think what i'll do for that is um i don't know uh do i want to make a new package i think i'll do this for now until it grows really bad let's create a package called fakes why don't you mock its functions well this is a good question um and there are complicated answers to this one being um as helpful as like mackay is for or makito those libraries are for testing um like you kind of end up breaking a cool a crucial principle in your test which is like you build this hard dependency on a third-party library um and like if i want to move off of mac k then i don't want it infiltrating every single one of my tests now there are ways to do this um hey justin welcome to the stream it is wednesday um there are ways to like put wrappers around these mocking libraries but sometimes i like kind of having control over um it's but we could look at a way of mocking the libraries if y'all are interested in doing that um what do you think do you want to see what i mean about how we could like mock or put a wrapper around the library um let's do it i'm actually and i'm gonna show uh uh no it's good for this stream uh everything i'm about to show you i learned from uh sam edwards and actually let me just show you his post while we're here um so to see uh he just shows an example of doing it but um oh so here's the original so here we like he's using my keto kotlin but which i actually wouldn't use i kind of like the mock k library but here let me zoom in we create a mock right and then we have this stuff like whenever function call then return and then we have all these verifications and we litter these around all of our tests in the app and that's a problem because if i again if for any reason i want to get um uh yeah oh good point like yeah it could be a problem if like the surface changes a lot but yeah like if any of this changes then i've got this problem all over the place right but um here's how we can actually make it a little nicer we still want to create a fake but instead of doing all the mocking ourselves which is kind of where i was about to head we just proxy that wrapping so here we still create a mock that is public to expose this is something we're going to have to do um but then we could just create a function that's like given this result right um and then here we've wrapped the ma makito stuff it's inside this function that we don't know and then this verification is the same way i don't really get this like syntax that he's using i wouldn't have written it this way at this naming convention but now we can see it's all hidden so our test now only interacts with a fake oven so if i want to get rid of my keto kotlin or i want to swap it out for another mocking library i only have to update my fake oven i don't need to update all of my tests so i think this is a good hybrid approach to get the benefit of mocking libraries without the strict dependency on mocking libraries so i think it's valid let's try it out for our app so let's look up mackay again this is the library that i really like to use and they're on version 1.12 so let's go ahead and throw this in our gradle file not that gradle file oh i need to click i want to clean up this file a lot but we'll do that also in another stream maybe we'll do a secondary developer experience stream because i think we can clean up a lot of how our gradle stuff is managed let's go into our face and our fake login repository so here we need to expose the repository so we can call this a login repository oh i see what you mean yeah i mean that's kind of what i was doing originally but now we're saying we're still using a mocking library uh without having to have that strong dependency on it um so what's one thing we're gonna have to do well one thing we're gonna have is like mock login with credentials it's not unrealistic to end up with 100 of these fake classes right at what point does it stop being beneficial um arguably never uh because you're just having the same benefit repeated 100 times um i suppose it's not beneficial if your individual dependencies are changing a lot and you're writing fakes that you don't need later um but like that's i guess something we can't really avoid right like it's it's the same benefit just kind of repeated a bunch of times um in my opinion we'll have this take in our credentials oh my god i really don't like that i have it in different spots but um so but then can't the same thing be said about our app player like one thing i think of with tess and why i love like the robot pattern you guys have seen me preach that a million times i'm like the importance of having um like the robot pattern as like a facade even to be used in unit tests is for some reason uh we take a lot of crucial topics that we know are really important inside our um our application but they seem to go out the window with testing people don't really think about wrapping libraries in testing people don't think about separation of concerns in testing but it matters right because sure it's not impacting your users and product isn't going to ask you like hey swap this out and test but you might want to do that like there might be a reason that you as a developer want to switch it out one day or maybe a whole new mocking library will come along that's even better and like you will want that and the same for all the same reasons we want these concepts in our actual application uh sure and i mean that's valid right like i'm not i'm not here to shame you for not doing this but like the the concern is much like our conversations and use cases right it's like my use case is unlikely to change i'm unlikely to you know maybe i change my login repository but i'm unlikely to change like the login use case talking to a login repository but i want to have that option in scalability should i need it and i think that it's valid for us to have that same mindset when it comes to writing our tests um okay so every this would be co every mock dot login credentials returns result so um yeah this is our fake implementation that fake implementation of a login repository that wraps all of our block work so let's use it let's actually write some tests here so one so let's say we want to well we'll have you know test successful login um we can say you know response we'll say login response auth token success that's what we'll put here yeah i mean tim brings up a good point um it's but but i find it fascinating that we're we're thinking that about like tests right because um i mean am i crazy in thinking that like we're taking a concept that we clearly recognize as important in our application code and we're arguing that it's not important in our test code and i understand the text code is different and i understand that it won't bite us in the same ways that it will bite us in our application code but i still think that's just some interesting uh like self-reflection that we can all do why why is our test code different why isn't it deserving of the same scalability considerations as our application code just thought uh okay so how do we test our successful login here well we're gonna have our repository we'll create a fake login repository um i'm going to say apply i'm going to say well actually we've got some other inputs here so let's say our credentials um will be email that's the bigtestbates.com password hunter 2. and yeah okay scalability is wrong but like maintainability right the ability to swap things out to swap out dependencies right to avoid hard dependencies on third-party tooling is something that we try not to do in our application code we're seeing in testing if the third-party tooling matches our design that matches what we need then why would i need to wrap it and i just like no one would ever say that about application code right we would say that no matter how good retrofit is you still want a repository layer and credentials result so okay so let's let me bring i'm going to rename this just declare input credentials we'll call this mock response and this one could be mac result okay so now that we've got our setup um what do we need to do well let's create our use case um well actually we could just say um result equals login repository use case oh wait no hold on sorry let's create the use case which is going to be prod credentials login use case uh with the login repository dot mac and our result will be use case credentials input credentials this is suspending so i want to run blocking i don't have run blocking test in here um sorry hold on we need the co routines test dependency so let me get that and i want to have the code routines test library hmm yeah i mean uh raphael brings up a good point right there like anything can happen that we can't predict that could be a reason for wanting to i hate this and this i don't know if i actually need it um to want to switch stuff out and so this application that we're building now has that uh capability um so i also want the truth library i don't know if you all have seen true but uh it's another really great way to have like fluent assertions inside our projects um let me add that real quick um ah okay so we've got a result so what we're going to do with this case is say we want to assert that result is equal to uh login result that's success yeah i think run blocking works i think run blocking test just gives you some additional information like it checks like um for like um yeah i've ran into weird issues too i'm hoping not today but it checks like uh any kind of routines that are running and stuff okay so we've got a successful login um let's write let's test unknown failure login um so here we can say um this will be result that failure whoops what do we call it i'll resolve that error throwable adam up we can throw that in there um so here we want to expect loginresult.failure more specifically loginresult.failure.unknown so um we basically did the same test but we changed our mock result and so now we're starting at fails but now chat we get into an interesting is the result your result yes i have what's okay use case result let's we'll call it use case results so we're very clear what we're doing and what we're comparing against uh so then it's clear between we have our mac result we have our use case result or i guess this is really the response this is the mock response from the repo um actual result works um i'm going to call this mac i don't know if i want to call it mac response no i'll keep it at my result um okay but we have well so here it's not what's um okay then let me clarify because this is not the expected result this is what gets returned by the repository this we expect will get mapped to this login result so results is all wrong even though that's the type this isn't what it is this is this is the mock login response that's what this really is this is the response from the repository so maybe mock login response is better um and actually let me just let's get rid of having this in two separate lines now um and that's what we can call it so we'll call it mac login response and then it's not a mac technically you're right you're right now i care because i want it to be and now like actual result doesn't really need to be specified like this is the result now login response and our results okay so now we've got um a whole nother uh naming convention and problem for us to work through i hope you guys are ready um which is thinking through the invalid credentials so we want to test invalid credential login and we need to think about so if i have invalid credentials what i'm expecting is the repo will return a result that error with some information saying there was invalid credentials uh but what do i do here do i want to like key on the throwable message or should i make my own throwable that is called invalid credentials or something um and just have that like extend throwable like uh the latter okay so in here we could say invalid credentials exception and uh this is basically extent throwable so a custom implementation of a variable that occurs when the user tries to log in with invalid credentials okay i like this actually um so then what we'll do is in our test we will have invalid credentials exception and so now we can assert that the result is invalid credentials so just to con keep with the tdd approach we are going to run this and see that they all fail and then we are going to update our use case to ensure that they pass and what do you mean my tests were not received why are you yelling at me oh do i need this anymore i don't need this that was just to satisfy the last pull request um and that's all that was yelling at me so let's run this again um i promise i will soon figure out how i can have music on the stream at the same time that i stream uh and not ruin it for the youtube videos i will work on that cool so these all failed with the not implemented error that's what we expected so that's fine let's now change that so here we're going to say let's get a response from the repo or let's call it repo result or something this will be login repository.log in with the credentials and now okay we're going to say return when can you do both simultaneously uh so i did do a stream where i had music on in the background the problem is when i take these stream recordings and i upload them to youtube i don't want the music there i've heard from a couple people they don't that people who are watching it on twitch they don't really mind but like people who are watching on youtube to understand what's happening they wanted to be music free um also i don't want youtube to yell at me for the music necessarily so until i can figure out how to strip the music from the recording uh i just have my stream silent but i know there are ways to do it yeah you can play your own music for that so let's return root switch on the repo result uh if this is result dot success um now in the future we want to store the auth token here that is something we're going to have to do eventually but for now let's just ignore that and return along and resolve that success otherwise we're going to have a result that error and now we're going to want to switch uh based on the repo result dot error that happened and now we're going to say okay well if this is a invalid credentials exception we want to return login result dot in failure.invalid credentials otherwise log and resolve that failure.unknown it's nested quite a bit isn't it um so let's all i'm gonna do to make this a little bit easier is say um let's say um what is wait where is my shortcut why isn't it happening i know i want my extract method i apparently don't have a shortcut for this wait command option m is that what i want yeah okay it just didn't work earlier um so here we're gonna say uh login result for failure so we're just splitting up a private function that takes in the failure or let's say error for consistency and maps it to right one checks the possible error scenarios for the repo results and maps it to an appropriate login result we can even say log in result have failure we want to return here and i don't like that when i extracted it i don't like this equals i like my brackets okay i know that i'm weird but i like it um okay so we clean this up a little bit this is gonna yell at me to inline this i don't like it i don't like it i'm not doing it how do i turn this off disable inspection great um okay this is coming in the future uh [Music] why is this aft return here now let's run our tests again and i think everything should pass i'm actually gonna i don't feel super guilty about this but i'm getting rid of this comment because i know i need to do it we will do it eventually we'll know where it goes and our test pass look at that we did some tdd so um that's that's the repository um we didn't make a like test implementation of the repository but we could do that in the next step i suppose we're going to say adding login repository and prod i don't test if i store the token you're right because i don't i don't store the token um do you think we should should we add um should we make a store auth token use case how can i test that here uh let's do it let's show you well let's start by um we can keep this in the login domain we could say store um auth token use case so let's make this an interface um second facebook after receiving an authentication token on login um we want to store that isn't just a functionality of the log in use case well one of the reasons why i thought of doing another layer is because um interesting no i'm not sure how i feel about it because where are we storing the token we're storing it in preferences right or most likely login repository to me again even though it's meant to be separate i kind of view this as like a one-to-one wrapper between like an api call but now we're saying that our login repo is responsible for both an api call and for storing information and i suppose that that's actually valid now that i say it out loud um and we can make this suspending because maybe we put it inside maybe we test out the new data store from jetpack but okay so datastore is nice i haven't looked at it yet the real question is tim do we need a value class for the auth token uh that might be the right thing to do um give it an off token throw that somewhere so that it can be retrieved or authenticating yeah okay that's actually another good point tim that's what i've done before it's like i didn't call it a repository i called it like a provider so you'd have like a user provider that would store and retrieve data related to the user or i guess we could call it an auth token provider it's a separate interface it's an auth token provider that is responsible for storing and fetching the store and auth token so maybe that's another yeah do we want to call it a provider or is that another repository like is auth token repository a bad idea it's a bad idea to have like an interface here um and then we have like store auth token and then batch often first one to answer wins auth token repository or user provider all right um yes you could scale around yeah i don't know why like a user repository the reason i don't like it is um yeah because it's not really the other thing is like um is this really doing anything related to the user like maybe i add functions in the future that store like an account id or something in addition to the auth token um well then tim brings up a good point if you potentially have repositories that are calling each other all right i don't like auth token repository for now right yeah i guess um um yeah you're all bringing up good points it's like no matter what we're kind of the reason i uh to wild dogs point actually is the reason i kind of liked the idea of auth token repository hey kalusi how are you the reason i like the convention of auth token repository is um like this sticks with our very strict like single responsibility principle uh ideas that we're going for it's like okay we have a repository that's responsible for storing and fetching so should it just be a store authority use case should we go all the way back to square one um maybe right um i kind of think that it makes sense like i just i want to store this piece of information that's a thing i want to do this this is screaming use case to me and like sure we could have it like yeah no i don't like i i kind of want to go down my rabbit hole first before i let chad steer me away on this one i'm gonna go down my own rabbit hole first we're going to store an auth token so restore i think in this case say after retrieving an auth token from logging in seems like it will always be used inside another use case yeah but that's fine right like i i think that that is valid a use case doesn't have to be only referenced by a view level in my opinion if it's a way of extracting out um specific functionality and hiding how this is stored and fetched just knowing that it needs to be use cases what a user can do within the future okay that's valid i don't like this i'm taking this out we're not doing it in the login repository i don't think it belongs there um i want to die on that hill if we don't want to make it a use case i think it needs to be a separate repository and that repository's responsibility is um an auth token repository and it's going to do what tim said and i think we're just kind of splitting hairs between provider and repository but it's the same idea um open string batch off token that's right this is what um i think we want here so this repository is responsible for fetching and storing a user's authentication token to a user's authentication okay um given an author can store that somewhere so it can be retrieved later and then fetches the auth token of the signed in user if we have one saved the auth token or null if not sound okay this is what i want to go with we're gonna throw all of that off token logic we just talked about inside of its own repository i think that this is making everyone happy it's not a use case it's not login work it is still its own uh single responsibility and so then what we can do here is in our credentials log in use case we could have an off token repository and then here in success we do auth token repository that's store auth token uh repo result dot theta dot auth token wait uh beta dot did i not hold on oh i made it private i'm so dumb that's why my autocomplete's not working i created the author pause very much module which is responsible for the important authentication apps that are off of customers central or the only place to fetch the refresh token and the access token yeah so i think what wild dog is describing is kind of what we just set up here um but someone else mentioned i think cp is that we could think ahead about uh maybe a poor idea of auth token being a string and maybe we need to make a data class for an auth token because what this would have is an auth token which will have whoops auth token which is a string and then a refresh token which is also a string so contains the information necessary for authenticating network requests so uh if i have this right auth token is the current token used to validate a user's request um a token used to generate a new off token if the current one is expired what a nice scenario to use some value classes let's do it let's just keep it going um wait no because i can't make a value class for auth token and use it inside a data class called auth token do i want to call this like authentication name the data class token ah you guys are naming everything today i love it the other thing is um i just realized with my email one um do i want it to be private am i gonna need to reference this later i think i might right or oh no i don't know i don't know how value classes work i don't know if it being private is a bad thing um this will yell at me for the unused private member thing again so i'm just going to throw this in here for now usually you do val value um okay uh yeah when we do the next part we'll actually um worry about that so maybe i'll do the same thing over in the email one we'll just call this value uh because the data or the value class says what it is okay so yeah okay that makes sense um but i think actually that this shouldn't be private because i will need to read from it eventually right so let's just not make them private that solves the first problem and that solves the static analysis problem okay cool i i actually have to say i really appreciate uh all of you who are active in chat tonight this has been like one of the most active streams i've ever done and even though it feels like pulling teeth i kind of love the structure that we've come up with here um i think this will scale really well as we go and then maybe this is actually an excuse to uh maybe clean up this mirror dock uh because even though technically it's about what we've done we've added more pieces so maybe we could update the dock at the end but um i digress we've got that we've got that that's cool okay so we store the auth token did i make this the suspending function i did i forgot to use the value classes whoops great catch what are you talking about we've written way more than five lines of code um okay so i did not do tdd here um let's do it let's comment this out and let's do this um let's comment it out and let's update our tests well the first thing is we have a new repository so we need new fake so in here we're going to have our mac and what are we going to need to knock well for this case we're just storing it so we're not actually doing a mock we're doing a verification and there's going to be two verifications we want to do the first one we're going to say verify token stored and this is going to consume oh um actually while we're here uh a couple things this needs to be changed to a token and then actually let's just call this yeah we could still call it nope we're going to change this to token repository executive decision so this will be a token story token we're just dropping the auth prefix um maybe we would actually want like a maybe we would want like fetch auth token fetch refresh token as their own thing uh but let's leave it as fetch token for now um then we can also rename this fake token repository oh no i don't know what just happened what did i do no i didn't want to under delete i just wanted to rename it i just want to fix my typo okay so here we want i could do a real fake with this one yeah uh but i was kind of going for consistency i suppose um so here we're gonna say verify token stored that will consume a token and then we'll do co-verify mac dot store token but now we also want a function to say verify that no token was stored on verifying no token stored and the way we'll do this is we'll do a code verify um we want to verify that store token was called with any parameter but the secret here is we want this to be called exactly zero times i think that black hay had like a never or something i i think there used to be something but i'm just gonna say exactly zero or maybe it was makita that had never but here is our uh necessary stuff here so let's do this we can probably clean up these tests we've got a lot copied and pasted across them but that's it so token repository will be a fake token repository um and then here we're gonna pass token repository that mock okay let's clean this line up let's throw that on its own lines ah we're back so and then let's take this and um oh i could create one it can be done with a plane confirmed verified mock oh was not called i didn't know that was a thing let me try that out um just going to replace my use case call on each of these tests i could definitely clean this up because again i've got the same use case created in every test and if that changes that could be annoying let's try that well here okay so here it's fine uh but this code verify um was not wrong that's not here i know they have some things like that let's look up the documentation um whoops i think i read they ah okay let me just see if they have verification wait why is it its own blog oh it's way there's verified stuff down here specifying exactly equals zero oh so was not called it looks like it's verifying that the mock was not called at all i could do this um so i guess we could do was that called here um i guess yeah this works um this would fail if we called something else i think like i'm no longer um no i think the lowercase works yeah oh good question i don't know maybe maybe there was something um i what's the word um like if i called a different function this could be an issue so i kind of want to go back to just the exactly zero i want to verify that this function was not called i guess in theory i would not want to interact with the mock at all if it failed um but let's just stick with that function for now um okay so we did that let's um what else can we do well now so this is invalid credentials so we could do token repository that verify no token stored in this test we're gonna do the same thing this is not a fail but here um uh uh oops um oh we're gonna have to change our login response class as well um let's do that first sorry oh this is so annoying i need to clean up these tests because that one thing alone broke all these tests let's refactor some stuff let's put default credentials will be these guys um let's put another thing for a test the default token refresh token refresh um we're also going to have let's say like a actually let's just let's leave it at that um and then yeah let's just do um the repositories in here um token repository fake type of whoops token repository it's fake typically okay we put a bunch of defaults up at the top let's clean up our test then so for our access success case what we can do is login response dot success uh wait did i not put okay login response default login response will be login response okay default token all right just um cleaning up uh some code here then sign up for the pixel 6 giveaway uh when i know when the pixel 6 is being given away you can ask actually i think yeah we'll leave this as it is i feel like some of that stuff is weird because some of these defaults are only used in one test so let's actually yeah let's pull it out i'm i'm being picky being picky about how i clean up my tests here login response so we've got our use case um and yeah so that's cleaned up so like we can get rid of that um here we can just do login repository dot mac login with credentials default credentials we can get rid of that line all default credentials here um more stuff up here get rid of that line login repository here and get rid of this line and default credentials here okay so let's run these tests they should fail at the moment because i commented out the good stuff um and let me so let me um wait why did they pass i thought we commented out the good stuff oh i know why uh so so these two failure tests they actually passed by default because i'm verifying that it's not called if the stuff is commented out of course it's not called but why did this test pass why did successful login pass well it's because i'm not making the assertion so let's do that token repository the verified token stored default token i have the same instance of the repo that's fine because i update the mock call in each test um maybe that's a little um iffy to do maybe i shouldn't do that but it's technically fine but you're right maybe i shouldn't have done that maybe the repo should be instantiated in each test but now login fails because it was expecting a verification that never happened so i'm gonna do that you're right i wanted to clean up code but you're right i don't think i think it's fine up here that we can like have some defaults but i don't know maybe i should go all the way back should i go all the way back should i have every test just do its own thing am i gonna hate having defaults i might because it might do some weird behavior it might be getting created for each one i feel might be right um oh i could do it before i've done that before actually pun intended so i've done like this and then what i'll do is like um set up and then we say login repository slot fake login repository repository i think raphael is right even though it doesn't seem like it i think he's right um why is this yelling at me no um okay the other thing that i don't like is you'll notice default credentials is referenced here twice in this test if i only change one of these lines i'm gonna have an issue um but so what i might do is like put a local one at the test and say ah this is default credentials and then here i keep this as credentials this is something i like to do as well um but let's let's keep the defaults i think it's fine for now and if this bites me in the future then i will change it but with all of that said i think what we can do now is we can uncomment this line why are you yelling at me no because since commenting it things have changed and now let's run a test i'm also going to check i've been streaming for a while and i want to make sure that mega doesn't need oh no we have a failure uh let's see if we can figure out why um no answer found for store token interesting interesting okay now let's try to figure out why um token is a data class um well i don't i don't want to make it relaxed i want the what i want to test i want to verify that it was called with the token that i i expected so this is actually implying that it was either never called or it was oh maybe that is why i need the relaxed you're right i do need to relax i thought that relaxed would like not do the verification but i'm wrong um it's fine i can do that so there's relax but there's also relaxing unit fun if you like only want to relax the unit functions which i think that we'll do here because we don't get a response from storing the token you're right that's why i failed i think let's find out um yeah okay relax works um another solution so see if you point out the co every another solution if you don't want to make it relaxed but you have a function that um you want like let's say you want to relax a specific function you can do co every moc.store token um just runs that's like a thing that you can do um but i think i'm gonna go with the relaxed units on ah prince got a cube solved okay let's um let's commit this code because this is actually i think pretty good um adding token repository for number seven uh i think that's pretty good and then that can actually be its own pull request in a second so let's do the cube solve let's do some pull requests and uh we've still got some viewers here we're still going strong maybe we can keep powering through an extra long stream tonight your next cap soon we'll we'll do cap soon i'm sure um but let's let me push that actually if you don't mind i'm gonna push that and then i'm also going to make the pull request so it can run while we do the cube solve so we're going to say adding login repository and token story then open enter um so that's the login repository to actually make login requests and updates our use case to store your token information so you're going to first construct the fresh instance of the class then invokes the entertainment method interesting let's get to that um well if we're actually curious like matt or prince both of you are mods do either of you know how to set up twitch predictions and uh do you want to set up a prediction for like over under 30 seconds um or actually what i was thinking of was like this like i'm kind of consistently under 30 so maybe a better prediction line would be like 27 and a half like are we gonna be over under 27 and a half seconds i don't if neither of you know how to set up a prediction we don't have to do it i will mix while you look because then you'd also have to set um like it's high for people to vote but we sh we should figure it out so we can do um prediction for these because then people can gamble their points and get closer to that caffeine and other fun stuff yeah i just i don't know how it works i'm fine is it under like manage rewards actually it might be in there wait why do i have a request cue oh it's just showing historic once see if i can figure this out there's gonna be documentation on it somewhere oh i wonder hold on is it only oh it is available to partners and affiliates um oh matt made one okay so um let's say before you set it up let's say oh cause there's there's a gap here so i was thinking we'd have to be clear about what the line is so we'll say um anything 2799 or faster we'll go to the first bucket 28 0 0 and up goes to the second bucket that's what we're going to say just to clarify about where 27 seconds lands are yeah if i get it in the 27 second gap nobody wins um what i don't know is um oh predictions are closed i wasn't open for very long we only got we only got one person can we cancel it and do another one and give like two minutes of time or something because i feel like that was we only got one vote in what i'll tell you what i will do a fun solve um just i will just do a fun solve while the mods figure out what they're doing we need to plan this better but i'll do one this one we're doing now means nothing all right they set up a prediction let's see how long they gave before it closes well tell me um i can't see how long as a broadcaster won't let me see how long they gave y'all to vote um but you all could probably see it five minutes okay i have an idea while we all are voting on that um my drink is empty i could use the restroom why don't we take a little five minute stream break uh and then we will come back and solve the rubik's cube and do a prediction if i come back before five minutes we'll hang out but this can give everyone a chance to get up stretch their legs real quick so let me uh switch back over here and chat seems like y'all were joking about stuff i need to figure out how to i have like the quick actions on the dashboard but i'm not seeing like um oh i can search quick actions oh my god now i can add a prediction okay and now i can see the countdown timer as well okay next time we have a thing i will do a prediction sudoku stream interesting idea i've thought about it i didn't want to rip off of cracking the cryptic but they do some cool stuff and i like want to um uh i like it it'd be cool i don't know it'd be fun for puzzles maybe i'll make that like a redemption or something but it would take me a while i could spend like 10 to 15 minutes on some of these harder ones um um okay while we wait for the next minute and 20 for that to finish actually let's go to this pull request the login use case let's merge it and then that i think what might affect this pull request we'll need to um now apparently it won't i'm surprised it does not uh because it's going into development which has a different thing but okay i guess because it was all similar commits wait you got yeah 18 seconds thank god that wasn't the prediction i would not be speaking oh do it twitch you could have twitch scramble my rubik's cube you all could just like mash the keyboard and scramble the rubik's cube uh and then make me solve it that would actually be pretty funny that would be pretty funny um two one all right let's let me take a look at this i'm actually nervous like those of you who bet hi as much as i want to be fast like y'all might be onto something here um because i'm nervous now but let's see what we can do ready um oh wow that was real bad oh that was real bad i was i thought i was going so good what happened there oh no oh no all right let's uh can we see did someone cash out oh six thousand channel points go to cp and four others mods can we bend him dang that was rough i'm upset it was a five minute break now that we have predictions under control next time it happens it will be a lot better so now i'm just worried like i'm gonna sign on next wednesday and sleepy's gonna redeem captain america right when i start i just know it he's probably loaded at this point i have i believed in me too i'm upset maybe it makes me go faster again right all right where are we at well one thing we can do is we can at least check off login repository on our list now um this will probably yell at me actually because um okay well here's one thing we need to do let's do this real quick check out development pull let's go back to our last branch and then merge in development because we want the poll request to only show what actually changed having a good night cp happy night prince i think everyone's getting man we still have viewers people are still hanging out i appreciate all of you um that gives me energy i'm ready to keep going um i will probably do as we approach the three hour mark here it will probably do another splice on the youtube videos um because no one wants to sit and watch three hours of the same youtube video uh sleeping tim people sleep during these hours um okay but this will actually yell at me because i need to update stream history um for the repository pr uh they're coming soon actually uh i talked to my uh manager um about the idea of taking a couple hours during my work week to do some streaming and they were okay with it uh as long as i kind of get through this current project i'm working on because i'm working on a really big one but he said that uh once we get through um the next couple sprints he would be totally okay with me doing that so not sure what days or times but they are coming so keep an eye out for that um updating stream history what is this add to get it going we don't care about that so yeah i'll find some time uh i'll let you know i think i'll probably stream kind of in like the morning-ish my time which would be like mid-afternoon for chunks of europe uh we'll see maybe i'll uh post something out on around for like some of the regulars and see who uh see if there's like certain people who want to see more of it or something or like have suggestions at times for something but uh yeah good night i hope i got good nights everyone who is helping or heading out but so wild dog if you're still here do you wake up for my streams or do you go to bed after my streams oh i'm assuming you wake up because that means it's now like 7 30 a.m but i don't know maybe you like have off working hours i'm just curious i used to have a regular from australia i think in melbourne and so for them it was like six o'clock in the morning so they would wake up uh when i started streaming i always loved hearing about that well i appreciate the youtube following i think that's true of a lot of people i have like next to know i have a small number of people who come catch the streams live but my views on youtube are actually quite a bit uh so i'm glad that people are finding them helpful did you i must have forgotten or maybe while though it's not your twitter handle i you probably did and i totally forgot all right have a good night siobhan um uh all right let's see where do we want to go tonight well um oh wait is this what is happening here did i break something when i merged let's do a clean build and let's see what happens let's make sure we don't have any issues i might have broken something when i merged um but then we can work on i don't know if we'll like well the next thing we're going to need to do is set up the view model and then once we have that then we need to go aha i just saw your dm now i understand thanks for connecting the dots um we'll need to set up the v metal but then there will be like the part of building the login screen and then we need to actually make sure that we can run it on our emulator and see stuff happen uh which will be um that will be fun uh let's take it a step at a time let's figure out why the ide is yelling at me um i'm not sure why oh i think because okay so i definitely broke something when i merged uh because this changed oh why is this oh let's delete this i think that's probably what i did wrong i think i just deleted a side oh no i'm still having issues what is happening oh this isn't needed anymore we knew that file could be gone um i don't know if you all know about the shortcut when you see at the top of your screen the package structure if you double click on a particular package it focuses it in your left hand pane so like i double click on this use case and now i see here's the file i want and i can right click delete right from there which is cool little android studio shortcut which one is that whoa that's cool did not know about that always something so this changes because this was wait did we actually use login type i don't think so right we decided not to use that that was from sample stuff so yeah we can delete the login type file yeah i'm always fascinated by like stuff that some android devs use a hundred times a day and um other people have never heard about it and like people say that on my stream all the time about some things they see me do and it's just it's fascinating how powerful the ide is and then it has all these cool little tricks that people don't know there's actually someone on twitter i wish i could run my name off that i had who's been doing like 100 days of android studio shortcuts uh you should follow them on twitter if you're not um it would be really great let me see if i could find that hater i guess there they are um yeah so shout out to aydah um go follow them on twitter if you want to see uh daily tricks from android studio i think they are on let's say find it um they're around the halfway point like 51 days 52 days uh what is ctrl g is that that open the search bar at the top for me what does it do all right everything's passing again um oh interesting um let me try that out uh where would that be used um i see uh is that not the same as like just if you do command f and then you hit enter it does the same thing now really it is control g okay come on oh i see oh whoa it selected all of them in a multi-cursor mode [Music] well so i highlighted the one i want control g testing wow this is very cool um i actually never use multi-cursor another thing though if you're using that for a variable you can also just do refactor and then it will refactor all of them at the same time um i'm not sure but maybe there's like a use case for not wanting to refactor maybe you're changing like documentations um who like christmas so um i remember interviewing someone one time and i accidentally stopped them without really thinking about what i'm saying and i was like whoa what'd you just do right there and then they got all defensive trying to explain their code and i'm like no no sorry your code is great what was that keyboard shirt cuz i was like i was like was one of my favorite things of interviewing android devs it's an excuse for me to learn new tricks because just by seeing other people use their id but i was kind of a i could have phrased it a little bit better um oh okay you're like changing a bunch of pri okay interesting i'm also gonna i'm gonna bump my tweet uh because we're still going because we're still going let me bump the uh oh presentations yeah that's what mine has um that's this green thing oh i guess it doesn't show up well it hid behind the window that's what this comes up on mine so if i do like double shift oh i guess when a pop-up window comes up it's hovering it i should make my windows not so large um but yes that's what i use the presentation assistant is what it's called i'm just kind of buying time because um i don't want to deal with merge issues again so i want this to run and then we'll merge this and then we'll we'll start working on the view model maybe i will just trust my instincts and merge this and hope i don't break anything every time you do an action don't use the keypad oh my god did you know there's a vim plug-in where it changes this portion here to use the vim uh like it's like typing in bin uh but still having all of the ide stuff um key promoter interesting let's let's set it up i'm curious oh my god where's the plugins i can't type oh and it's also a promoter wow two and a half million installs um do i really want to restart on stream uh yolo what's the worst that could happen when you restart android studio oh okay i was i was gonna ask like how do i what's a good way to test it but i see run being a good way to test it also this past year i'm not gonna wait for the ui test one to run because they haven't changed so it should pass so let's just uh add that squash and marriage nice okay um let's switch back over to development real quick i clicked on that damn link didn't i okay nothing popped up i guess i didn't um and let's make a new branch real quick okay but first so you're saying if i hit this oh command debug missed one time okay all right i i will try this out i'll try this out for a little bit i think i will hate it i might also disable the run one but um that's fine all right so
Info
Channel: Adam McNeilly
Views: 635
Rating: undefined out of 5
Keywords: Android
Id: TWeu9fRNPWY
Channel Id: undefined
Length: 99min 32sec (5972 seconds)
Published: Sun Oct 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.