// package mock -- инфраструктура для тестирования
package mock

import (
	"fmt"
	"os"

	"git.p78su.freemyip.com/svi/gostore/pkg/mock/mock_service"
	"git.p78su.freemyip.com/svi/gostore/pkg/serv_http"
	"git.p78su.freemyip.com/svi/gostore/pkg/store"
	"git.p78su.freemyip.com/svi/gostore/pkg/types"
)

func MakeMock() (types.IService, error) {
	os.Unsetenv("STORE_HTTP_PORT")
	os.Setenv("STORE_HTTP_PORT", "25000")
	serv := mock_service.NewMockService()
	var err error
	serv.Store_, err = store.NewStore(serv)
	if err != nil {
		return nil, fmt.Errorf("MakeMock(): in create Store, err=\n\t%w", err)
	}
	serv.ServHttp_, err = serv_http.NewServHttp(serv)
	if err != nil {
		return nil, fmt.Errorf("MakeMock(): in create ServHttp, err=\n\t%w", err)
	}
	return serv, err
}
