Skip to content

Introduce ShellExecutor, add tests for GitKtx#105

Merged
f-meloni merged 3 commits intodanger:masterfrom
davidbilik:feature/shell-executor
Jul 13, 2020
Merged

Introduce ShellExecutor, add tests for GitKtx#105
f-meloni merged 3 commits intodanger:masterfrom
davidbilik:feature/shell-executor

Conversation

@davidbilik
Copy link
Contributor

Introduce abstract ShellExecutor with one specific implementation
used in production code. This is useful for tests when we want to
isolate our test from actual shell commands. Use this abstraction in
tests for Git changed lines extensions.

@davidbilik davidbilik force-pushed the feature/shell-executor branch 3 times, most recently from b2f9fcb to 9ca70e1 Compare July 7, 2020 05:33
gianluz added a commit that referenced this pull request Jul 8, 2020
Copy link
Member

@gianluz gianluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #107 as reference 😄 something like that


return process.inputStream.bufferedReader().readText()
fun exec(command: String, arguments: List<String> = emptyList()): String {
return ShellExecutorFactory.get().execute(command, arguments)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't really like the idea of proxy here, we can directly use utils

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that was what we discussed with @f-meloni in my previous PR 🤔

fun execute(command: String, arguments: List<String> = emptyList()): String
}

class ShellExecutorImpl : ShellExecutor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ShellExecutorImpl with related factory can be deleted then

*/
internal class GitKtxTest {

class MockShellExecutor : ShellExecutor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using a mock library? i was planning to add mockk.. let's use that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I personally don't use mock libraries, I prefer fakes, but in this context it's probably better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@f-meloni f-meloni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer this implementation.
Utils is an object that is created to help who uses danger and does too many things to be used internally where I would like instead some composition internally

@davidbilik
Copy link
Contributor Author

Btw this PR also fixes an issue with swapped additions/deletions computation in changed lines. I've discovered that during tests, which made me feel good that the tests were useful. But on the other hand now is version 0.6.0 released that contains this bug :(

@davidbilik
Copy link
Contributor Author

So what do you guys suggest to do with this PR?

@f-meloni
Copy link
Member

f-meloni commented Jul 9, 2020

So what do you guys suggest to do with this PR?

I’m happy to see this merged, is great, we just need to fix the indentation and the merge conflict :)

Introduce abstract ShellExecutor with one specific implementation
used in production code. This is useful for tests when we want to
isolate our test from actual shell commands. Use this abstraction in
tests for Git changed lines extensions.
@davidbilik davidbilik force-pushed the feature/shell-executor branch from e2fa634 to 4c3f695 Compare July 10, 2020 04:21
@davidbilik
Copy link
Contributor Author

So what do you guys suggest to do with this PR?

I’m happy to see this merged, is great, we just need to fix the indentation and the merge conflict :)

Ok then, conflict resolved, indentation fixed and I've added mockK to the project and used that in my test

@f-meloni
Copy link
Member

So what do you guys suggest to do with this PR?

I’m happy to see this merged, is great, we just need to fix the indentation and the merge conflict :)

Ok then, conflict resolved, indentation fixed and I've added mockK to the project and used that in my test

I preferred it without mockK to be fair, I don't think it added much value here, but is not a good reason to hold this PR, we can discuss this separately

@f-meloni f-meloni merged commit bfb1332 into danger:master Jul 13, 2020
@davidbilik
Copy link
Contributor Author

I preferred it without mockK to be fair, I don't think it added much value here, but is not a good reason to hold this PR, we can discuss this separately

Well @gianluz suggested using mock library and you did not comment on that review so I thought that you don't have anything against that 🤷 your review of this PR were kind of clashing with each other so I don't know what should I work on and what not

@davidbilik davidbilik deleted the feature/shell-executor branch July 14, 2020 06:34
@f-meloni
Copy link
Member

I preferred it without mockK to be fair, I don't think it added much value here, but is not a good reason to hold this PR, we can discuss this separately

Well @gianluz suggested using mock library and you did not comment on that review so I thought that you don't have anything against that 🤷 your review of this PR were kind of clashing with each other so I don't know what should I work on and what not

We don't always agree on everything, otherwise we would be the same person :D
As I said this is a discussion that goes out of the scope of the PR, then I merged it anyway, and then will discuss separately what we want to do :)
This PR was good as it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants