local subject = require("devcontainer.internal.executor")

describe("devcontainer.internal.executor:", function()
  describe("given existing executable", function()
    describe("is_executable", function()
      it("should return true", function()
        local success = subject.is_executable("nvim")
        assert.is_true(success)
      end)
    end)
    describe("ensure_executable", function()
      it("should not fail", function()
        local success = pcall(subject.ensure_executable, "nvim")
        assert.is_true(success)
      end)
    end)
  end)
  describe("given existing executable full command", function()
    describe("is_executable", function()
      it("should return true", function()
        local success = subject.is_executable("nvim --version")
        assert.is_true(success)
      end)
    end)
    describe("ensure_executable", function()
      it("should not fail", function()
        local success = pcall(subject.ensure_executable, "nvim --version")
        assert.is_true(success)
      end)
    end)
  end)
  describe("given missing executable", function()
    describe("is_executable", function()
      it("should return false", function()
        local success = subject.is_executable("doker")
        assert.is_not_true(success)
      end)
    end)
    describe("ensure_executable", function()
      it("should fail", function()
        local success = pcall(subject.ensure_executable, "doker") -- intentional typo
        assert.is_not_true(success)
      end)
    end)
  end)
end)
