all repos

gopher.nvim @ v0.2.2

Minimalistic plugin for Go development

gopher.nvim/spec/integration/iferr_test.lua(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local t = require "spec.testutils"
local child, T = t.setup "iferr"

T["iferr"]["should add if != nil {"] = function()
  local rs = t.setup_test("iferr/iferr", child, { 8, 2 })
  child.cmd "GoIfErr"
  child.cmd "write"

  t.eq(t.readfile(rs.tmp), rs.fixtures.output)
  t.cleanup(rs)
end

T["iferr"]["should add if err with custom message"] = function()
  child.lua [[
    require("gopher").setup {
      iferr = { message = 'fmt.Errorf("failed to %w", err)' }
  } ]]

  local rs = t.setup_test("iferr/message", child, { 6, 2 })
  child.cmd "GoIfErr"
  child.cmd "write"

  t.eq(t.readfile(rs.tmp), rs.fixtures.output)
  t.cleanup(rs)
end

return T