-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shared-state-async: improves format adds simple test
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/shared-state-async/tests/test_rpcd_shared-state-async.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local testUtils = require "tests.utils" | ||
local sharedState = require("shared-state") | ||
local json = require("luci.jsonc") | ||
|
||
local testFileName = "packages/shared-state-async/files/usr/libexec/rpcd/shared-state-async" | ||
local sharedStateRpc = testUtils.load_lua_file_as_function(testFileName) | ||
local rpcdCall = testUtils.rpcd_call | ||
|
||
--sicce there is no Shared State async binary, testing posiblilites are reduced | ||
--manual testing can be done on a routeer with bat-hosts package using this: | ||
-- # ubus -S call shared-state-async getFromSharedState "{'data_type': 'bat-hosts'}" | ||
-- # ubus -S call shared-state-async getFromSharedState "{'data_type': 'bat-hosss'}" | ||
-- {"error":"invalid_data_type"} | ||
-- # ubus -S call shared-state-async sync "{'data_type': 'bat-hosts' ,'peers_ip':['10.0.0.1','10.0.0.2']}'" | ||
-- {"status":"success"} | ||
-- # ubus -S call shared-state-async sync "{'data_type': 'bat-hosts' ,'peers_ip':['10.0.0.1','10.0..2']}'" | ||
-- {"error":"invalid_peer_address"} | ||
-- # ubus -S call shared-state-async sync "{'data_type': 'bat-hoss' ,'peers_ip':['10.0.0.1','10.0.0.2']}'" | ||
-- {"error":"invalid_data_type"} | ||
|
||
|
||
|
||
describe('ubus-shared-state tests #ubus-shared-state', function() | ||
before_each('', function() | ||
testDir = testUtils.setup_test_dir() | ||
sharedState.DATA_DIR = testDir | ||
sharedState.PERSISTENT_DATA_DIR = testDir | ||
end) | ||
|
||
after_each('', function() | ||
testUtils.teardown_test_dir() | ||
end) | ||
|
||
it('test list methods', function() | ||
local response = rpcdCall(sharedStateRpc, {'list'}) | ||
assert.is.equal("value", response.getFromSharedState.data_type) | ||
assert.is.equal("value", response.sync.data_type) | ||
assert.is.equal("value", response.sync.peers_ip) | ||
|
||
end) | ||
end) |