All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 local eq = assert.are.same
2 local ale = require("ale")
4 describe("ale.get_filename_mappings", function()
10 nvim_buf_get_var = function(buffer, key)
11 local buffer_table = buffer_map[buffer] or {}
12 local value = buffer_table[key]
15 error(key .. " is missing")
30 before_each(function()
31 buffer_map = {[42] = {}}
35 it("should return the correct mappings for given linters/fixers", function()
36 vim.g.ale_filename_mappings = {
41 eq({{"foo", "bar"}}, ale.get_filename_mappings(42, "a"))
42 eq({{"baz", "foo"}}, ale.get_filename_mappings(42, "b"))
43 eq({}, ale.get_filename_mappings(42, "c"))
45 buffer_map[42].ale_filename_mappings = {b = {{"abc", "xyz"}}}
47 eq({}, ale.get_filename_mappings(42, "a"))
48 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, "b"))
49 eq({}, ale.get_filename_mappings(42, "c"))
52 it("should return arrays set for use with all tools", function()
53 vim.g.ale_filename_mappings = {{"foo", "bar"}}
55 eq({{"foo", "bar"}}, ale.get_filename_mappings(42, "a"))
56 eq({{"foo", "bar"}}, ale.get_filename_mappings(42, ""))
57 eq({{"foo", "bar"}}, ale.get_filename_mappings(42, nil))
59 buffer_map[42].ale_filename_mappings = {{"abc", "xyz"}}
61 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, "a"))
62 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, ""))
63 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, nil))
66 it("should let you use * as a fallback", function()
67 vim.g.ale_filename_mappings = {
69 ["*"] = {{"abc", "xyz"}},
72 eq({{"foo", "bar"}}, ale.get_filename_mappings(42, "a"))
73 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, "b"))
74 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, ""))
75 eq({{"abc", "xyz"}}, ale.get_filename_mappings(42, nil))