Skip to content

Commit 12c8628

Browse files
committed
add and optimized.
1 parent 29aa60a commit 12c8628

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

internal/fetcher/dwnews/fetcher_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ func TestFetchUrls(t *testing.T) {
4545
}
4646

4747
func TestFmtBodyDwnews(t *testing.T) {
48-
raw, _ := gears.HttpGetBody("https://www.dwnews.com/中国/60179204", 10)
48+
raw, _ := gears.HttpGetBody("https://www.dwnews.com/全球/60201177", 10)
4949
body, _ := FmtBodyDwnews(raw)
5050
t.Run("test fetch summary then fmt it: ", func(t *testing.T) {
51-
summary := "> 台湾总统蔡英文正式展开第二任期,美国国务院5月20日表示,批准以1.8亿美元向台湾出售18枚重量级鱼雷。此举料进一步加剧华盛顿与北京已经紧张的关系。"
52-
if strings.Contains(body, summary) {
53-
fmt.Println("Success")
54-
} else {
55-
fmt.Println("Cannot fetch summary correctly.")
51+
summary := "中国与印度军队6月15日再次在边境爆发严重冲突,造成至少20名印军丧生,印度高层官员19日表示,中方指挥官和副指挥官也在这起冲突中丧生。中国未透露中方的伤亡细节。"
52+
if !strings.Contains(body, summary) {
53+
t.Errorf("got:\n%v", body)
5654
}
57-
5855
})
5956
}

main_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestSaveOneDwnew(t *testing.T) {
8+
SaveOneDwnew("https://www.dwnews.com/全球/60201177")
9+
}

0 commit comments

Comments
 (0)