Documentation ¶
Overview ¶
Package testhelper provides test helpers which don't depend on viamcartographer
Package testhelper provides test helpers which don't depend on viamcartographer
Index ¶
- Constants
- func ClearDirectory(t *testing.T, path string)
- func CreateIntegrationSLAMService(t *testing.T, cfg *vcConfig.Config, timedLidar s.TimedLidar, ...) (slam.Service, error)
- func CreateSLAMService(t *testing.T, cfg *vcConfig.Config, logger logging.Logger) (slam.Service, error)
- func CreateTimestampFilename(dataDirectory, lidarName, fileType string, timeStamp time.Time) string
- func InitInternalState(t *testing.T, includeEditedMap bool) (string, func())
- func InitTestCL(t *testing.T, logger logging.Logger) func()
- func IntegrationCartographer(t *testing.T, existingMap string, subAlgo viamcartographer.SubAlgo, ...) []byte
- func ResetFolder(path string) error
- func SetupStubDeps(lidarName, movementSensorName s.TestSensor, t *testing.T) resource.Dependencies
Constants ¶
const ( // NumPointCloudFiles is the number of mock lidar data files we want to use for the // integration tests. The files are stored in the mock_data/lidar slam artifact directory. NumPointCloudFiles = 10 // NumMovementSensorData is the amount of mock movement sensor data we want to use for the // integration tests. The data is stored in the mock_data/movement_sensor/data.txt slam artifact file. NumMovementSensorData = 40 )
const ( // SlamTimeFormat is the timestamp format used in the dataprocess. SlamTimeFormat = "2006-01-02T15:04:05.0000Z" // CartoFacadeTimeoutForTest is the timeout used for capi requests for tests. CartoFacadeTimeoutForTest = 5 * time.Second // CartoFacadeInternalTimeoutForTest is the timeout used for internal capi requests for tests. CartoFacadeInternalTimeoutForTest = 15 * time.Minute // LidarWithErroringFunctions is a lidar whose functions return errors. LidarWithErroringFunctions s.TestSensor = "stub_lidar" // MovementSensorWithErroringFunctions is a movement sensor whose functions return errors. MovementSensorWithErroringFunctions s.TestSensor = "stub_movement_sensor" // NoMovementSensor is a movement sensor that represents that no movement sensor is set up or added. NoMovementSensor s.TestSensor = "" )
Variables ¶
This section is empty.
Functions ¶
func ClearDirectory ¶
ClearDirectory deletes the contents in the path directory without deleting path itself.
func CreateIntegrationSLAMService ¶
func CreateIntegrationSLAMService( t *testing.T, cfg *vcConfig.Config, timedLidar s.TimedLidar, timedMovementSensor s.TimedMovementSensor, logger logging.Logger, ) (slam.Service, error)
CreateIntegrationSLAMService creates a slam service for testing.
func CreateSLAMService ¶
func CreateSLAMService( t *testing.T, cfg *vcConfig.Config, logger logging.Logger, ) (slam.Service, error)
CreateSLAMService creates a slam service for testing.
func CreateTimestampFilename ¶
CreateTimestampFilename creates an absolute filename with a primary sensor name and timestamp written into the filename.
func InitInternalState ¶
InitInternalState creates the internal state directory within a temp directory with an internal state pbstream file & returns the data directory & a function to delete the data directory.
func InitTestCL ¶
InitTestCL initializes the carto library & returns a function to terminate it.
func IntegrationCartographer ¶
func IntegrationCartographer( t *testing.T, existingMap string, subAlgo viamcartographer.SubAlgo, logger logging.Logger, online bool, useIMU bool, useOdometer bool, enableMapping bool, expectedMode cartofacade.SlamMode, ) []byte
IntegrationCartographer is responsible for running a viam-cartographer process using the desired mock sensors. Once started it will wait for all data to be processed by monitoring sensor channels. After data has been fully processed, the endpoints Position, PointCloudMap, and InternalState are evaluated, and the process is closed out. The final internal state of cartographer is then returned.
func ResetFolder ¶
ResetFolder removes all content in path and creates a new directory in its place.
func SetupStubDeps ¶
func SetupStubDeps(lidarName, movementSensorName s.TestSensor, t *testing.T) resource.Dependencies
SetupStubDeps returns stubbed dependencies based on the camera the stubs fail tests if called.
Types ¶
This section is empty.