FOSSology  4.4.0
Open Source License Compliance by Open Source Software
testDatabase.c File Reference

Unit test cases for db operations. More...

#include <testRun.h>
#include <database.h>
#include <scheduler.h>
#include <utils.h>
Include dependency graph for testDatabase.c:

Go to the source code of this file.

Functions

void test_database_init ()
 Test for database_init() More...
 
void test_database_exec_event ()
 Test for database_exec_event() More...
 
void test_database_update_event ()
 Test for database_update_event() More...
 
void test_database_update_job ()
 Test for database_update_job() More...
 
void test_database_job ()
 Test for database_job_processed(),database_job_log(),database_job_priority() More...
 
void test_email_notify ()
 Test for email_notification() More...
 

Variables

char sqltmp [1024] = {0}
 
char * check_scheduler_tables
 
char * jobsql_processed
 
CU_TestInfo tests_database []
 
CU_TestInfo tests_email []
 

Detailed Description

Unit test cases for db operations.

Definition in file testDatabase.c.

Function Documentation

◆ test_database_exec_event()

void test_database_exec_event ( )

Test for database_exec_event()

Test:
  1. Initialize database and call database_exec_event()

Definition at line 77 of file testDatabase.c.

◆ test_database_init()

void test_database_init ( )

Test for database_init()

Todo:
not complete
Test:
  1. Call database_init() with a scheduler
  2. Check if the required tables with required columns are created

Definition at line 37 of file testDatabase.c.

◆ test_database_job()

void test_database_job ( )

Test for database_job_processed(),database_job_log(),database_job_priority()

Test:
  1. Initialize test database
  2. Create a mock job
  3. Call database_job_processed() to update items processed
  4. Call database_job_log() to create a test log
  5. Call database_job_priority() to update job priority
Todo:
Add checks for function calls

Definition at line 190 of file testDatabase.c.

◆ test_database_update_event()

void test_database_update_event ( )

Test for database_update_event()

Test:
  1. Initialize test database
  2. Call database_update_event()
  3. Check if new jobs are added to the queue with proper names
  4. Reset the queue

Definition at line 102 of file testDatabase.c.

◆ test_database_update_job()

void test_database_update_job ( )

Test for database_update_job()

Test:
  1. Initialize test database
  2. Create a mock job
  3. Check the job status
  4. Call database_update_job() to update the job status
  5. Check if the job status is not changed for the structure but updated in DB

Definition at line 141 of file testDatabase.c.

◆ test_email_notify()

void test_email_notify ( )

Test for email_notification()

Test:
  1. Initialize scheduler, DB and email
  2. Create a job and update status using database_update_job()
  3. Check if job checkedout by email

Definition at line 237 of file testDatabase.c.

Variable Documentation

◆ check_scheduler_tables

char* check_scheduler_tables
extern

Check column names for a given table

Definition at line 22 of file sqlstatements.h.

◆ jobsql_processed

char* jobsql_processed
extern

Update the items processed for the given job id

Definition at line 175 of file sqlstatements.h.

◆ tests_database

CU_TestInfo tests_database[]
Initial value:
=
{
{"Test database_init", test_database_init },
{"Test database_exec_event", test_database_exec_event },
{"Test database_update_event", test_database_update_event},
{"Test database_update_job", test_database_update_job },
{"Test database_job", test_database_job },
CU_TEST_INFO_NULL
}
void test_database_init()
Test for database_init()
Definition: testDatabase.c:37
void test_database_update_job()
Test for database_update_job()
Definition: testDatabase.c:141
void test_database_update_event()
Test for database_update_event()
Definition: testDatabase.c:102
void test_database_job()
Test for database_job_processed(),database_job_log(),database_job_priority()
Definition: testDatabase.c:190
void test_database_exec_event()
Test for database_exec_event()
Definition: testDatabase.c:77

Definition at line 263 of file testDatabase.c.

◆ tests_email

CU_TestInfo tests_email[]
Initial value:
=
{
{"Test email_notify", test_email_notify },
CU_TEST_INFO_NULL
}
void test_email_notify()
Test for email_notification()
Definition: testDatabase.c:237

Definition at line 273 of file testDatabase.c.