Closed mint-thompson closed 8 years ago
see #4
Nice (Never thought someone would use this)
I think it will now break the test and while doing the array thing seems correct, the test requires to be rewritten.
1) LuaStandalone: SMW\Scribunto\Tests\ScribuntoLuaLibraryResultsTest[2]: getQueryResult (meta count)
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-{
- "Modification date",
-}
+ERROR: attempt to index field 'printrequests' (a nil value)
{ name = 'getQueryResult (meta count)',
func = function ( args )
local ret = mw.ext.smw.getQueryResult( args )
return ret.printrequests[0].label
end,
args = { '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' },
expect = { 'Modification date' }
}
I'm not that familiar with Lua but I think this should fix the test:
local testframework = require 'Module:TestFramework'
-- Tests
local tests = {
--getQueryResult
{ name = 'getQueryResult (empty query)', func = mw.ext.smw.getQueryResult,
args = { '' },
expect = { nil }
},
{ name = 'getQueryResult (printrequests label)',
func = function ( args )
local ret = mw.ext.smw.getQueryResult( args )
for k,v in pairs(ret.query.printrequests ) do
return v.label
end
end,
args = { '[[Modification date::+]]|?Modification date|limit=0|mainlabel=-' },
expect = { 'Modification date' }
}
}
return testframework.getTestProvider( tests )
Thanks (tests pass now)
This change should be available by tomorrow on the sandbox.
Thank you!
Wrap return value of getQueryResult in an array so that the entire result object will be transmitted.