utility

package
v0.0.0-...-7a7e0a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = log.New(os.Stdout, "", log.LstdFlags)

Functions

func ConvertCSVToFloat32List

func ConvertCSVToFloat32List(input string) []float32

ConvertCSVToFloat32List takes a comma-separated string of numbers and returns a slice of float32, handling conversion errors by skipping invalid values

func ConvertCSVToFloat64List

func ConvertCSVToFloat64List(input string) []float64

ConvertCSVToFloat64List takes a comma-separated string of numbers and returns a slice of float64, handling conversion errors by skipping invalid values

func ConvertCSVToInt64List

func ConvertCSVToInt64List(input string) []int64

ConvertCSVToInt64List takes a comma-separated string of numbers and returns a slice of int64, handling conversion errors by skipping invalid values

func ConvertCSVToIntList

func ConvertCSVToIntList(input string) []int64

func ConvertCSVToList

func ConvertCSVToList(input string) []string

ConvertCSVToList takes a comma-separated string and returns a slice of strings

func ConvertExpectedResult

func ConvertExpectedResult(input []map[string]interface{}) []map[string]interface{}

ConvertExpectedResult processes the expected results from test cases by converting values into appropriate Go types based on the specified 'datatype'. It handles primitive types (text, int, bigint, float, double, boolean, timestamp), map types (map<text, int>, map<timestamp, text>, etc.), and set types (set<int>, set<text>, etc.). This function ensures that the expected result format matches the structure of the actual database query results for accurate comparison during testing.

func ConvertParams

func ConvertParams(t *testing.T, params []map[string]interface{}, fileName, query string) []interface{}

convertParams converts parameters to the correct Go types based on their expected Cassandra data types

func ConvertToMap

func ConvertToMap(t *testing.T, param map[string]any, fileName, query string) map[string]interface{}

ConvertToMap converts a map[string]interface{} to map[string]interface{} with converted values

func ConvertValue

func ConvertValue(t *testing.T, param map[string]any, fileName, query string) any

ConvertValue converts a value to the corresponding Go type based on the Cassandra datatype

func LogError

func LogError(t *testing.T, filename, opDesc, query string, err error)

LogError logs an error when query execution fails.

func LogFailure

func LogFailure(t *testing.T, filename, opDesc, query, diff string)

LogFailure logs a query execution failure with expected vs actual differences.

func LogFatal

func LogFatal(msg string)

LogFatal logs a critical error message and exits the application.

func LogInfo

func LogInfo(msg string)

LogInfo logs general info messages.

func LogSectionDivider

func LogSectionDivider()

LogSectionDivider logs a section divider for test case separation.

func LogSuccess

func LogSuccess(t *testing.T, opDesc, queryType string)

LogSuccess logs a successful query execution with optional test integration.

func LogTestError

func LogTestError(msg string)

LogWarning logs warnings or unexpected but non-fatal conditions.

func LogTestFatal

func LogTestFatal(t *testing.T, msg string)

LogWarning logs warnings or unexpected but non-fatal conditions.

func LogWarning

func LogWarning(t *testing.T, msg string)

LogWarning logs warnings or unexpected but non-fatal conditions.

func SetupLogger

func SetupLogger(logFileName string, enableFileLogging bool) (*os.File, error)

SetupLogger initializes logging to both a file and console if file logging is enabled.

Types

type ConversionError

type ConversionError struct {
	Value     interface{}
	Type      string
	Operation string
	Err       error
}

ConversionError represents an error that occurs during type conversion

func (*ConversionError) Error

func (e *ConversionError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL