dugite icon indicating copy to clipboard operation
dugite copied to clipboard

execTask.cancel()

Open maifeeulasad opened this issue 3 years ago • 3 comments

First I tried this, something like this:

temp.mkdirSync('desktop-git-clone-and-cancel')
...
const result = GitProcess.execTask(
      ['clone', '--', 'https://github.com/maifeeulasad/maifeeulasad.github.io', '.'],
      testCancelRepoPath,
      options
    )
expect(await result.cancel()).toBe(GitTaskCancelResult.successfulCancel)

But it gave me: exitCode › returns exit code when folder is empty

So I tried fs.mkdtemp(_,folder)

But now I get: exitCode › handles stdin closed errors

maifeeulasad avatar Sep 06 '21 15:09 maifeeulasad

I can see, all these exit codes/messages are somehow related to other tests. But I'm not familiar with these. Can you guys help me here? @sergiou87 @tidy-dev

maifeeulasad avatar Sep 06 '21 15:09 maifeeulasad

@sergiou87 that didn't work. But there are some questions, I wanted to know, like:

  • if the clone test is done here with --, why remove that in this case, cause our method is just an extension to that.
  • what does this error code even mean? git-process › exitCode › returns exit code when folder is empty

maifeeulasad avatar Sep 22 '21 05:09 maifeeulasad

I think part of the problem is you are using an async version of mkdtemp, try this:

  it('clone-and-cancel', async () => {
    const tempDir = path.join(os.tmpdir(), 'desktop-git-clone-and-cancel-')

    const folder = fs.mkdtempSync(tempDir)
    const options = {
      env: setupNoAuth()
    }

    const task = GitProcess.execTask(
      ['clone', '--', 'https://github.com/maifeeulasad/maifeeulasad.github.io', '.'],
      folder,
      options
    )
    const cancelResult = await task.cancel()
    await task.result
    expect(cancelResult).toBe(GitTaskCancelResult.successfulCancel)
  })

Of course that test is incorrect, but should be a good base to start working on! 😄

sergiou87 avatar Sep 24 '21 09:09 sergiou87

Superseded by #495

sergiou87 avatar Sep 05 '22 08:09 sergiou87