testconfig

package
v0.0.0-...-3ca3677 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PackageInfo

type PackageInfo int

func (PackageInfo) ConvertOsPath

func (i PackageInfo) ConvertOsPath(s string) string

convert path strings in a string provided

func (PackageInfo) DirExists

func (i PackageInfo) DirExists(path string) (bool, error)

DirExists checks if a dir exist

func (PackageInfo) GetPackageRootDir

func (i PackageInfo) GetPackageRootDir(package_path string) (exist bool, path string)

GetPackageRootDir gets the location of a package dir mostly useful for test cases

func (PackageInfo) JoinPath

func (i PackageInfo) JoinPath(paths []string) string

os join paths

type TestCases

type TestCases struct {
	Name        string                 `json:"name,omitempty"`
	Enabled     bool                   `json:"enabled,omitempty"`
	TestData    map[string]interface{} `json:"test_data,omitempty"`    // map[string]interface{}{"test_data": []interface{}}
	ExpectsData map[string]interface{} `json:"expects_data,omitempty"` // map[string]interface{}{"expects_data": []interface{}}
}

test case objects { "name" : "PROTEST",

"cases": [
   {
      "name": "TestName1",   // function name of the test case
      "enabled": true,        // flag to determine if we do the test case or skip
      "TestData" : map[string][interface{ }] // list of test data by name
      "ExpectsData" : map[string][interface{}] // expects results
   },
   {
     ....
   },

] }

type TestConfig

type TestConfig struct {
	Cases []TestCases `json:"cases,omitempty"` // "cases":[]
	Name  string      `json:"name,omitempty"`  // "name": "PROTEST",
}

test case objects

see testcases.go for test case methods

{ "name" : "PROTEST",

"cases": [
   {
     ...
   },

] }

func (*TestConfig) Equal

func (tc *TestConfig) Equal(source interface{}, target interface{}) bool

Equal determin numeric type and determine equality

func (*TestConfig) EqualFaceI

func (tc *TestConfig) EqualFaceI(f interface{}, i int) bool

EqualFaceI compare test data to a int num

func (*TestConfig) EqualFaceS

func (tc *TestConfig) EqualFaceS(is interface{}, s string) bool

EqualFaceS Compare interface to string doesn't seem to really be needed....

func (*TestConfig) GetExpectsData

func (tc *TestConfig) GetExpectsData(tc_name string, k string) interface{}

GetExpectsData gets expects data, returns interface because the data type is unknown use tc Equal arguments for type comparison, conversions or assert the type

func (*TestConfig) GetTestCases

func (tc *TestConfig) GetTestCases(tc_name string) (t TestCases)

GetTestCases gets a test case by name

func (*TestConfig) GetTestData

func (tc *TestConfig) GetTestData(tc_name string, k string) interface{}

GetTestData gets test data

func (*TestConfig) GetTestingConfiguration

func (tc *TestConfig) GetTestingConfiguration(config_name string)

GetTestingConfiguration gets config for testing Examples cv := tc.GetExpectsData("TestGetAPIVersion", "CurrentVersion") log.Infof("tc test_data -> %s\n", tc.EqualFaceI(cv, 120)) log.Infof("2 tc compare s -> %s\n", tc.GetExpectsData("TestGetAPIVersion", "FakeData") == "foo") log.Infof("tc compare s -> %s\n", tc.EqualFaceS(tc.GetExpectsData("TestGetAPIVersion", "FakeData"), "foo")) log.Infof("get no test data -> %+v \n", tc.GetTestData("TestGetAPIVersion", "Surprise")) log.Infof("is test enabled -> %+v \n", tc.IsTestEnabled("TestGetAPIVersion"))

func (*TestConfig) IsGreater

func (tc *TestConfig) IsGreater(source interface{}, target interface{}) bool

IsGreater source number greater than target

func (*TestConfig) IsGreaterEqual

func (tc *TestConfig) IsGreaterEqual(source interface{}, target interface{}) bool

IsGreaterEqual source greater or equal than target

func (*TestConfig) IsTestEnabled

func (tc *TestConfig) IsTestEnabled(tc_name string) bool

IsTestEnabled is test case enabled? defaults are always true

func (*TestConfig) NewTestConfig

func (tc *TestConfig) NewTestConfig() *TestConfig

setup Testing

func (*TestConfig) UnMarshallTestingConfig

func (tc *TestConfig) UnMarshallTestingConfig(json_data []byte)

UnMarshallTestingConfig json to data

Jump to

Keyboard shortcuts

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