|
@@ -4,6 +4,7 @@ import (
|
|
|
"os"
|
|
|
"testing"
|
|
|
|
|
|
+ "git.p78su.freemyip.com/svi/gostore/pkg/serv_http"
|
|
|
"git.p78su.freemyip.com/svi/gostore/pkg/store"
|
|
|
)
|
|
|
|
|
@@ -27,6 +28,33 @@ func TestMock(t *testing.T) {
|
|
|
func (sf *tester) create() {
|
|
|
sf.t.Log("create")
|
|
|
sf.createBad1()
|
|
|
+ sf.createBad2()
|
|
|
+ sf.createGood1()
|
|
|
+}
|
|
|
+
|
|
|
+func (sf *tester) createGood1() {
|
|
|
+ sf.t.Log("createGood1")
|
|
|
+ serv, err := MakeMock()
|
|
|
+ if err != nil {
|
|
|
+ sf.t.Fatalf("createGood1(): err = %v", err)
|
|
|
+ }
|
|
|
+ if serv == nil {
|
|
|
+ sf.t.Fatalf("createGood1(): serv == nil")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Ошибка при создании HTTP-сервера
|
|
|
+func (sf *tester) createBad2() {
|
|
|
+ sf.t.Log("createBad2")
|
|
|
+ serv_http.IsBad_ = true
|
|
|
+ serv, err := MakeMock()
|
|
|
+ if err == nil {
|
|
|
+ sf.t.Fatalf("createBad2(): err == nil")
|
|
|
+ }
|
|
|
+ if serv != nil {
|
|
|
+ sf.t.Fatalf("createBad2(): serv != nil")
|
|
|
+ }
|
|
|
+ serv_http.IsBad_ = false
|
|
|
}
|
|
|
|
|
|
// Ошибка при создании хранилища
|
|
@@ -35,10 +63,10 @@ func (sf *tester) createBad1() {
|
|
|
store.IsBad_ = true
|
|
|
serv, err := MakeMock()
|
|
|
if err == nil {
|
|
|
- sf.t.Error("createBad1(): err == nil")
|
|
|
+ sf.t.Fatalf("createBad1(): err == nil")
|
|
|
}
|
|
|
if serv != nil {
|
|
|
- sf.t.Error("createBad1(): serv != nil")
|
|
|
+ sf.t.Fatalf("createBad1(): serv != nil")
|
|
|
}
|
|
|
store.IsBad_ = false
|
|
|
}
|