Ver código fonte

SVI Добавление тестов топику; 19.9%

SVI 2 anos atrás
pai
commit
071ad1399a
1 arquivos alterados com 14 adições e 3 exclusões
  1. 14 3
      internal/dict_topic/topic/topic_test.go

+ 14 - 3
internal/dict_topic/topic/topic_test.go

@@ -11,7 +11,8 @@ import (
 */
 
 type tester struct {
-	t *testing.T
+	t     *testing.T
+	topic *Topic
 }
 
 func TestTopic(t *testing.T) {
@@ -36,13 +37,23 @@ func (sf *tester) createGood1() {
 		BinMsg:  []byte{},
 		StrUuid: "",
 	}
-	topic, err := NewTopic(msg)
+	var err error
+	sf.topic, err = NewTopic(msg)
 	if err != nil {
 		sf.t.Fatalf("createGood1(): err=%v", err)
 	}
-	if topic == nil {
+	if sf.topic == nil {
 		sf.t.Fatalf("createGood1(): topic==nil")
 	}
+	if stat := sf.topic.Stat(); stat == nil {
+		sf.t.Fatalf("createGood1(): stat==nil")
+	}
+	if msg1 := sf.topic.Get(); msg1 != msg {
+		sf.t.Fatalf("createGood1(): msg!=msg1")
+	}
+	if name := sf.topic.Name(); name != "test_topic" {
+		sf.t.Fatalf("createGood1(): name(%q)!='test_Topic'", name)
+	}
 }
 
 // Нет имени топика