tests: Add tests for WpSettings object

- settings.c tests conf file loading & parsing, metadata updates,
  wpsetttings object creation and its API.
- settings.lua tests the API from lua scripts.
- Add a sample settings.conf file, this file contains sections copied
  over from client.conf along with the settings section. Add a file
  each for wp side and lua side of scripts.
- Make changes in base test infrastructure to take a custom conf file.
- Enhance the wp_settings_get_instance_api() to be take metadata_name
  parameter. So, Wpsetttings is now a singleton instance for a given
  metadata file.
- Enhance the m-settings module also to be take metadata_name parameter.
  this is handy for lua side of tests as its cumbersome to do this is
  lua.
This commit is contained in:
Ashok Sidipotu
2022-03-31 12:27:22 +05:30
committed by Julian Bouzas
parent 8fd8b01b7a
commit 4d7ce2292e
13 changed files with 768 additions and 31 deletions

View File

@@ -1472,11 +1472,17 @@ impl_module_new (lua_State *L)
}
}
static int
get_setting (lua_State *L)
static gboolean
get_boolean (lua_State *L)
{
const char *setting = luaL_checkstring (L, 1);
WpSettings *s = wp_settings_get_instance (get_wp_core (L));
const char *metadata_name = NULL;
if (lua_type (L, 2) == LUA_TSTRING)
metadata_name = luaL_checkstring (L, 2);
WpSettings *s = wp_settings_get_instance (get_wp_core (L), metadata_name);
if (s)
{
gboolean value = wp_settings_get_boolean (s, setting);
@@ -1488,7 +1494,7 @@ get_setting (lua_State *L)
}
static const luaL_Reg settings_methods[] = {
{ "get_setting", get_setting },
{ "get_boolean", get_boolean },
{ NULL, NULL }
};