Exemple #1
0
int test_sky_action_file_load() {
    int rc;
    struct tagbstring path = bsStatic("tests/fixtures/action_files/0");
    
    // Initialize and load action file.
    sky_action_file *action_file = sky_action_file_create();
    sky_action_file_set_path(action_file, &path);
    rc = sky_action_file_load(action_file);
    mu_assert_int_equals(rc, 0);

    // Assert actions.
    mu_assert_int_equals(action_file->action_count, 2);

    sky_action_file_free(action_file);
    return 0;
}
Exemple #2
0
// Initializes and opens the action file on the table.
//
// table - The table to initialize the action file for.
//
// Returns 0 if successful, otherwise returns -1.
int sky_table_load_action_file(sky_table *table)
{
    int rc;
    check(table != NULL, "Table required");
    check(table->path != NULL, "Table path required");

    // Unload any existing action file.
    sky_table_unload_action_file(table);

    // Initialize action file.
    table->action_file = sky_action_file_create();
    check_mem(table->action_file);
    table->action_file->path = bformat("%s/actions", bdata(table->path));
    check_mem(table->action_file->path);

    // Load data
    rc = sky_action_file_load(table->action_file);
    check(rc == 0, "Unable to load actions");

    return 0;
error:
    sky_table_unload_action_file(table);
    return -1;
}