Merge branch 'master' into systemversion

This commit is contained in:
redorav 2018-04-14 11:23:44 +01:00 committed by GitHub
commit 9f1b32fa23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 2 deletions

View File

@ -137,8 +137,12 @@
-- --
function context.mergeFilters(ctx, src) function context.mergeFilters(ctx, src)
for k,v in pairs(src.terms) do for k, v in pairs(src.terms) do
ctx.terms[k] = v if k == "tags" then
ctx.terms[k] = table.join(ctx.terms[k], v)
else
ctx.terms[k] = v
end
end end
end end

View File

@ -73,3 +73,41 @@
-- detoken in extended context should result in value set in that environ. -- detoken in extended context should result in value set in that environ.
test.isequal("text", ext.targetname) test.isequal("text", ext.targetname)
end end
--
-- mergeFilters should behave as expected for tags
--
function suite.mergeFilters()
ctx = { terms = { tags = { "ctxtags" } } }
src = { terms = { tags = { "srctags" } } }
context.mergeFilters(ctx, src)
result = { terms = { tags = { "ctxtags", "srctags" } } }
test.isequal(result, ctx)
end
function suite.mergeFilters_keeptype()
ctx = { terms = { kind = "ConsoleApp" } }
src = { terms = { kind = "ConsoleApp" } }
context.mergeFilters(ctx, src)
test.isequal("string", type(ctx.terms.kind))
end
function suite.mergeFilters_createtable()
ctx = { terms = { tags = "ctxtags" } }
src = { terms = { tags = "srctags" } }
context.mergeFilters(ctx, src)
result = { terms = { tags = { "ctxtags", "srctags" } } }
test.isequal(result, ctx)
end