mock.go 843 B

123456789101112131415161718192021222324252627282930
  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. serv.CancelApp()
  23. serv.Wg().Wait()
  24. return nil, fmt.Errorf("MakeMock(): in create ServHttp, err=\n\t%w", err)
  25. }
  26. return serv, err
  27. }