Browse Source

SVI Доработка тестов; 77.7%

user 9 months ago
parent
commit
758c313eac
1 changed files with 35 additions and 0 deletions
  1. 35 0
      pkg/mock/mock_test.go

+ 35 - 0
pkg/mock/mock_test.go

@@ -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
+}