Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
12 I improved my tests a bit. I can now select which file(s) to run, which makes it a lot easier to test the things that are normally at the end.
I still need to think of something so I can skip testing the tests about the "user" resource. Currently it is needed as that contains the stuff that logs the test program in.

If I can log my test program in and out without running code from the thing that I'm actually testing I would be able to have my tests run in whatever order, allowing me to dynamically link the test files. Which would make it just that bit easier and reduce chance of errors.

I'm also thinking about adding functionality that makes it generate some tests on the fly.
That way I for example only have to give it an url like
rp/{rpCode}/characters/{charCode}/modifiers/{modId}
together with what each value a placeholder needs to contain.

After that it will first fill them all in with BS, then fill 1 correct in, the other two with BS until they all have had 1 correct. After that it will fill in 2 correct and after all that is done it will fill in all 3 of them correctly.

That would make it much easier for me to write tests. Right now, I need to write all those combinations by hand, for each url and each method that url has....
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
11 First project of the semester in my CSCI class has been revealed. It's effectively 1 player battleship on an NxM grid, with the computer placing the pieces randomly. Ought to be fun, though the placement algorithm is going to be a massive pain.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
10 despite me being rather unproductive due to reasons, I at least managed to write some of the code I talked about yesterday.

Now, it just needs to be able to do more then just get requests and play more then just the url. After that, writing tests should be a lot easier :)
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
8 My prof told us today that we shouldn't use for loops for mathematical things like factorial... because you don't always start at zero with your count variable, and your conditional will likely be <= instead of <
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
8 My prof told us today that we shouldn't use for loops for mathematical things like factorial... because you don't always start at zero with your count variable, and your conditional will likely be <= instead of <
9 because recursion is so much better /s
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
9 Its actually kind of funny how little differences there are between a for or a while loop in many languages.
I wouldn't be surprised if for loops got introduced to reduce errors from forgetting to properly check or forgetting to add to the count. However, in a lot of languages the for loop doesn't do much to prevent this.

Its one of the few things I like about python, where its for loop is actually nothing more then a foreach loop, though I do like Lua's for loops better.
 

GamerwithnoGame

Over-Achiever
Jan 29, 2015
2,808
1,507
224
10. I made a start! I mean, not much of a start, admittedly, but a start! I finally found an area with blue mist and sparkles for my Astral Sorcery setup (that baby's going up in the clouds), and I began the central building to house my solar panel and computer setup. I got the solar panel up there, just need to sort out that roof now, put a lift in, then start filling it out a little.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
10 and... it now handles every request kind :)
Code:
local simpleTestData = {
       name  = "testMod",
       value  =  4,
       countDown =  -2,
       intName  =  "ATK"
     }
     print("insert modifier")
     local id = fun:generateGetTests({
       urlParts = {"rp","rpCode","characters","charCode","modifiers"},
       urlData  = {rpCode = "1234567",charCode="char123"},
       method  = fun.post,
       requiredData = simpleTestData,
       checkData = {
         missing  = {code=422},
         notFound = {code=404},
         correct  = {code=201}
       }
     })
     print(id)
     simpleTestData.intName = nil
     print("update modifier")
     fun:generateGetTests({
       urlParts = {"rp","rpCode","characters","charCode","modifiers","modId"},
       urlData  = {rpCode = "1234567",charCode="char123",modId=id},
       method  = fun.put,
       requiredData = simpleTestData,
       checkData = {
         missing  = {code=422},
         notFound = {code=404},
         correct  = {code=200}
       }
     })
     print("delete modifier")
     fun:generateGetTests({
       urlParts = {"rp","rpCode","characters","charCode","modifiers","modId"},
       urlData  = {rpCode = "1234567",charCode="char123",modId=id},
       method  = fun:switch(fun.delete)
     })
That is all I need (and I can obviously shrink it even more) to create my tests now.
This will first test how the program reacts when both rpCode and charCode are not filled in correctly. Then with only one of them not filled in correctly. It then checks the other.
After that it will make few other requests where one of the things in requiredData is missing and after it made sure that everything is requiredData is actually required it finally does a request where everything is filled in correctly.

It then does pretty much the same thing but a put request instead of a post to see if we can update properly and then does the same to delete said modifer
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
I should really get a better handle on web server stuff. I mean, I don't need it, but it seems useful.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
I should really get a better handle on web server stuff. I mean, I don't need it, but it seems useful.
12?
Those tests aren't what I would call web server stuff. The only thing it does is making HTTP requests and reseting a database.

In other news, I managed to remove some functions and a whole class without breaking the tests. So.. the file MY_Controller is getting a bit more workable :)