本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 line
1.1KB

  1. package testfixtures
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6. var (
  7. // ErrWrongCastNotAMap is returned when a map is not a map[interface{}]interface{}
  8. ErrWrongCastNotAMap = errors.New("Could not cast record: not a map[interface{}]interface{}")
  9. // ErrFileIsNotSliceOrMap is returned the the fixture file is not a slice or map.
  10. ErrFileIsNotSliceOrMap = errors.New("The fixture file is not a slice or map")
  11. // ErrKeyIsNotString is returned when a record is not of type string
  12. ErrKeyIsNotString = errors.New("Record map key is not string")
  13. // ErrNotTestDatabase is returned when the database name doesn't contains "test"
  14. ErrNotTestDatabase = errors.New(`Loading aborted because the database name does not contains "test"`)
  15. )
  16. // InsertError will be returned if any error happens on database while
  17. // inserting the record
  18. type InsertError struct {
  19. Err error
  20. File string
  21. Index int
  22. SQL string
  23. Params []interface{}
  24. }
  25. func (e *InsertError) Error() string {
  26. return fmt.Sprintf(
  27. "testfixtures: error inserting record: %v, on file: %s, index: %d, sql: %s, params: %v",
  28. e.Err,
  29. e.File,
  30. e.Index,
  31. e.SQL,
  32. e.Params,
  33. )
  34. }
上海开阖软件有限公司 沪ICP备12045867号-1