mock.go 796 B

12345678910111213141516171819202122232425262728
  1. // package mock -- инфраструктура для тестирования
  2. package mock
  3. import (
  4. "fmt"
  5. "os"
  6. "git.p78su.freemyip.com/svi/gostore/pkg/mock/mock_service"
  7. "git.p78su.freemyip.com/svi/gostore/pkg/serv_http"
  8. "git.p78su.freemyip.com/svi/gostore/pkg/store"
  9. "git.p78su.freemyip.com/svi/gostore/pkg/types"
  10. )
  11. func MakeMock() (types.IService, error) {
  12. os.Unsetenv("STORE_HTTP_PORT")
  13. os.Setenv("STORE_HTTP_PORT", "25000")
  14. serv := mock_service.NewMockService()
  15. var err error
  16. serv.Store_, err = store.NewStore(serv)
  17. if err != nil {
  18. return nil, fmt.Errorf("MakeMock(): in create Store, err=\n\t%w", err)
  19. }
  20. serv.ServHttp_, err = serv_http.NewServHttp(serv)
  21. if err != nil {
  22. return nil, fmt.Errorf("MakeMock(): in create ServHttp, err=\n\t%w", err)
  23. }
  24. return serv, err
  25. }