|
@@ -1,9 +1,44 @@
|
|
|
package mock
|
|
|
|
|
|
import (
|
|
|
+ "os"
|
|
|
"testing"
|
|
|
+
|
|
|
+ "git.p78su.freemyip.com/svi/gostore/pkg/store"
|
|
|
)
|
|
|
|
|
|
+type tester struct{
|
|
|
+ t *testing.T
|
|
|
+}
|
|
|
+
|
|
|
func TestMock(t *testing.T) {
|
|
|
+ fnClear := func() {
|
|
|
+ _ = os.RemoveAll("./store")
|
|
|
+ }
|
|
|
+ fnClear()
|
|
|
+ defer fnClear()
|
|
|
+ sf := &tester{
|
|
|
+ t: t,
|
|
|
+ }
|
|
|
+ sf.create()
|
|
|
+}
|
|
|
|
|
|
+// Создание мок-сервиса
|
|
|
+func (sf *tester) create() {
|
|
|
+ sf.t.Log("create")
|
|
|
+ sf.createBad1()
|
|
|
}
|
|
|
+
|
|
|
+// Ошибка при создании хранилища
|
|
|
+func (sf *tester) createBad1() {
|
|
|
+ sf.t.Log("createBad1")
|
|
|
+ store.IsBad_ = true
|
|
|
+ serv, err := MakeMock()
|
|
|
+ if err == nil {
|
|
|
+ sf.t.Error("createBad1(): err == nil")
|
|
|
+ }
|
|
|
+ if serv != nil {
|
|
|
+ sf.t.Error("createBad1(): serv != nil")
|
|
|
+ }
|
|
|
+ store.IsBad_ = false
|
|
|
+}
|