Add two functions that assist in testing a TypedPipe#1478
Add two functions that assist in testing a TypedPipe#1478johnynek merged 4 commits intotwitter:developfrom richwhitjr:develop
Conversation
There was a problem hiding this comment.
Is it worth having a flavor like
def checkOutputTransform[T, U](input: List[T])(transform: TypedPipe[T] => TypedPipe[U])(assertions: List[T] => Unit) =
assertions(checkOutputInline(transform(TypedPipe.from(input))))
Or doing TypedPipe.from we should leave to the test writer?
There was a problem hiding this comment.
Sure that actually may be nice to have.
There was a problem hiding this comment.
same comment here: make the return generic please.
There was a problem hiding this comment.
can we put a return type on all methods?
also, what about mre general:
def checkOutputTransform[T, U, R](input: List[T])(transform: TypedPipe[T] => TypedPipe[U])(assertions: List[U] => R): R =then you could use methods that return other than unit.
There was a problem hiding this comment.
any reason not to call this inMemoryToList or something?
There was a problem hiding this comment.
I like this name for this function. I kind of like idea of keeping the names for the others though since it really is just a nice to have utility function for running some asserts on a typed pipe and the name indicates that it probably should only be used for unit testing.
If you think it could be used outside of tests though we can try to think of some better names.
|
ready to merge, just some name bikeshedding. |
|
Is there any need for the checkOutputTransform part? |
|
Mostly just a simple utility function. Not strictly needed. You could imagine have a function that checks a TypedPipe that you may want reuse on different tests so it could be a little cleaner to use the checkOutput function. Sometimes just having the function where you are doing the testing can make the test a little more readable. I can see the transform being useful when you have some function of TypedPipe[T] -> TypedPipe[U] and you want to test this. This is common in many of my real world tests. |
Add two functions that assist in testing a TypedPipe
Many times when testing a scalding job you just want to test a function that takes a TypedPipe and returns another TypedPipe. This can be difficult using JobTest. TypedPipeChecker makes use of Executions to pull the given TypedPipe into memory so that can asserts can be run against the resulting List.