mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 05:19:38 +08:00
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
//go:build localtest
|
||
|
||
package uixt
|
||
|
||
import (
|
||
"testing"
|
||
|
||
"github.com/stretchr/testify/assert"
|
||
)
|
||
|
||
func TestVideoCrawler(t *testing.T) {
|
||
setupAndroid(t)
|
||
|
||
configs := &VideoCrawlerConfigs{
|
||
AppPackageName: "com.ss.android.ugc.aweme",
|
||
Timeout: 600,
|
||
|
||
Feed: FeedConfig{
|
||
TargetCount: 5,
|
||
TargetLabels: []TargetLabel{
|
||
{Text: `^广告$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
|
||
{Text: `^图文$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true, Target: 2},
|
||
{Text: `^特效\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
|
||
{Text: `^模板\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
|
||
{Text: `^购物\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
|
||
},
|
||
SleepRandom: []interface{}{0, 5, 0.7, 5, 10, 0.3},
|
||
},
|
||
Live: LiveConfig{
|
||
TargetCount: 3,
|
||
SleepRandom: []interface{}{15, 20},
|
||
},
|
||
}
|
||
err := driverExt.VideoCrawler(configs)
|
||
checkErr(t, err)
|
||
}
|
||
|
||
func TestRemoveNonAlphanumeric(t *testing.T) {
|
||
testData := []struct {
|
||
input string
|
||
expect string
|
||
}{
|
||
{"@Hello 你好123#@!", "Hello你好123"},
|
||
{"@夏夏在发呆。", "夏夏在发呆"},
|
||
{"@·霖霖", "霖霖"},
|
||
{"@我❤️小云朵", "我小云朵"},
|
||
}
|
||
|
||
for _, data := range testData {
|
||
out := removeNonAlphanumeric(data.input)
|
||
assert.Equal(t, data.expect, out)
|
||
}
|
||
}
|