<commit_before>package dbsearch

import (
	"testing"
)

func Test_Exception(t *testing.T) {
	s := init_test_data()
	s.SetDebug(false)
	if s != nil {
		//_01_exception_load_test(t, s)
	}
	//t.Fatal("Success [no error] test")
}

/*
	Check SType field
*/
func _01_exception_load_test(t *testing.T, s *Searcher) {
	var autoload_mTestType *AllRows = &AllRows{}

	var err error = nil
	defer func() {
		if err == nil {
			t.Fatalf("No catch error for empty SType\n")
		}
	}()

	if err := s.PreInit(autoload_mTestType); err == nil {
		t.Fatalf("No catch error for empty SType\n")
	}

}<commit_msg>Adds test for check exception<commit_after>package dbsearch

import (
	"log"
	"reflect"
	"runtime"
	"testing"
)

func Test_Exception(t *testing.T) {
	s := init_test_data()
	s.SetDebug(false)
	if s != nil {
		//_01_exception_load_test(t, s)
		//_02_exception_load_test(t, s)
	}
	//t.Fatal("Success [no error] test")
}

/*
	Check SType field
*/
func _01_exception_load_test(t *testing.T, s *Searcher) {

	var autoload_mTestType *AllRows = &AllRows{}

	var err error = nil
	defer func() {
		if err == nil {
			t.Fatalf("No catch error for empty SType\n")
		}
	}()

	if err := s.PreInit(autoload_mTestType); err == nil {
		t.Fatalf("No catch error for empty SType\n")
	}

}

type exception_05_TestPlace struct {
	Col1 int `db:"col1" type:"serial"`
	Col2 int `db:"col2" type:"int"`
}

var exception_05_mTestType *AllRows = &AllRows{
	SType: reflect.TypeOf(exception_05_TestPlace{}),
}

func _02_exception_load_test(t *testing.T, s *Searcher) {
	runtime.GOMAXPROCS(1)

	sql_create := " CREATE TABLE public.test " +
		"( col1 serial, col2 text )"

	sql_cols := "INSERT INTO public.test(col2) "
	sql_vals := []string{
		" VALUES ('ee')",
		" VALUES ('ee')",
		" VALUES ('ee')",
	}

	make_t_table(s, sql_create, sql_cols, sql_vals)

	p := []exception_05_TestPlace{}
	s.GetFork(exception_05_mTestType, &p, "SELECT * FROM public.test ORDER BY 1")

	face, err := s.GetFaceFork(exception_05_mTestType, "SELECT * FROM public.test ORDER BY 1")
	if err != nil {
		t.Fatal(err)
	}
	log.Printf("\n%#v\n", face)

	//check_face_json(t, face[0], "_21_exception_test")
}
{'fraction_non_alphanumeric': 0.15535797847449695, 'fraction_numerical': 0.01731399157697707, 'mean_word_length': 4.127098321342926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6058155', 'n_tokens_mistral': 913, 'n_tokens_neox': 864, 'n_words': 198}