<commit_before>#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <gst/check/gstcheck.h>

#include "gstd_session.h"


GST_START_TEST (test_successful_create)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p0", "fakesrc ! fakesink");
  fail_if (GSTD_EOK != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_no_name)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, NULL, NULL);
  fail_if (GSTD_MISSING_NAME != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_no_description)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p2", NULL);
  fail_if (GSTD_MISSING_ARGUMENT != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_erroneous_description)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p3", "fakesrc !");
  fail_if (GSTD_BAD_DESCRIPTION != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


static Suite *
gstd_create_suite (void)
{
  Suite *suite = suite_create ("gstd_create");
  TCase *tc = tcase_create ("general");

  suite_add_tcase (suite, tc);
  tcase_add_test (tc, test_successful_create);
  tcase_add_test (tc, test_create_no_name);
  tcase_add_test (tc, test_create_no_description);
  tcase_add_test (tc, test_create_erroneous_description);

  return suite;
}

GST_CHECK_MAIN (gstd_create);<commit_msg>Rename succesful pipeline create test to match hierarchy convention<commit_after>#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <gst/check/gstcheck.h>

#include "gstd_session.h"


GST_START_TEST (test_create_successful)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p0", "fakesrc ! fakesink");
  fail_if (GSTD_EOK != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_no_name)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, NULL, NULL);
  fail_if (GSTD_MISSING_NAME != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_no_description)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p2", NULL);
  fail_if (GSTD_MISSING_ARGUMENT != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


GST_START_TEST (test_create_erroneous_description)
{
  GstdObject *node;
  GstdReturnCode ret;
  GstdSession *test_session = gstd_session_new ("Test_session");

  ret = gstd_get_by_uri (test_session, "/pipelines", &node);
  fail_if (ret);
  fail_if (NULL == node);

  ret = gstd_object_create (node, "p3", "fakesrc !");
  fail_if (GSTD_BAD_DESCRIPTION != ret);

  gst_object_unref(node);
  gst_object_unref(test_session);
}
GST_END_TEST;


static Suite *
gstd_create_suite (void)
{
  Suite *suite = suite_create ("gstd_create");
  TCase *tc = tcase_create ("general");

  suite_add_tcase (suite, tc);
  tcase_add_test (tc, test_create_successful);
  tcase_add_test (tc, test_create_no_name);
  tcase_add_test (tc, test_create_no_description);
  tcase_add_test (tc, test_create_erroneous_description);

  return suite;
}

GST_CHECK_MAIN (gstd_create);
{'fraction_non_alphanumeric': 0.11991247264770241, 'fraction_numerical': 0.001312910284463895, 'mean_word_length': 5.771851851851852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7223286', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1807, 'n_words': 337}