Skip to content

Commit

Permalink
chore: make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
RikaCelery committed Oct 12, 2024
1 parent 6050559 commit 0f30441
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type mockAPICaller struct{}

func (m mockAPICaller) CallApi(_ APIRequest) (APIResponse, error) {
func (m mockAPICaller) CallAPI(_ APIRequest) (APIResponse, error) {
return APIResponse{
Status: "",
Data: gjson.Result{},
Expand All @@ -37,12 +37,12 @@ func TestPattern_Text(t *testing.T) {
pattern *Pattern
expected bool
}{
{[]message.MessageSegment{message.Text("haha")}, NewPattern().Text("haha"), true},
{[]message.MessageSegment{message.Text("aaa")}, NewPattern().Text("not match"), false},
{[]message.MessageSegment{message.Image("not a image")}, NewPattern().Text("not match"), false},
{[]message.MessageSegment{message.At(114514)}, NewPattern().Text("not match"), false},
{[]message.MessageSegment{message.Text("你说的对但是ZeroBot-Plugin 是 ZeroBot 的 实用插件合集")}, NewPattern().Text("实用插件合集"), true},
{[]message.MessageSegment{message.Text("你说的对但是ZeroBot-Plugin 是 ZeroBot 的 实用插件合集")}, NewPattern().Text("nonono"), false},
{[]message.Segment{message.Text("haha")}, NewPattern().Text("haha"), true},
{[]message.Segment{message.Text("aaa")}, NewPattern().Text("not match"), false},
{[]message.Segment{message.Image("not a image")}, NewPattern().Text("not match"), false},
{[]message.Segment{message.At(114514)}, NewPattern().Text("not match"), false},
{[]message.Segment{message.Text("你说的对但是ZeroBot-Plugin 是 ZeroBot 的 实用插件合集")}, NewPattern().Text("实用插件合集"), true},
{[]message.Segment{message.Text("你说的对但是ZeroBot-Plugin 是 ZeroBot 的 实用插件合集")}, NewPattern().Text("nonono"), false},
}
for i, v := range textTests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Expand All @@ -60,13 +60,13 @@ func TestPattern_Image(t *testing.T) {
pattern *Pattern
expected bool
}{
{[]message.MessageSegment{message.Text("haha")}, NewPattern().Image(), false},
{[]message.MessageSegment{message.Text("haha"), message.Image("not a image")}, NewPattern().Image().Image(), false},
{[]message.MessageSegment{message.Text("haha"), message.Image("not a image")}, NewPattern().Text("haha").Image(), true},
{[]message.MessageSegment{message.Image("not a image")}, NewPattern().Image(), true},
{[]message.MessageSegment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image(), false},
{[]message.MessageSegment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image().Image(), true},
{[]message.MessageSegment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image().Image().Image(), false},
{[]message.Segment{message.Text("haha")}, NewPattern().Image(), false},
{[]message.Segment{message.Text("haha"), message.Image("not a image")}, NewPattern().Image().Image(), false},
{[]message.Segment{message.Text("haha"), message.Image("not a image")}, NewPattern().Text("haha").Image(), true},
{[]message.Segment{message.Image("not a image")}, NewPattern().Image(), true},
{[]message.Segment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image(), false},
{[]message.Segment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image().Image(), true},
{[]message.Segment{message.Image("not a image"), message.Image("not a image")}, NewPattern().Image().Image().Image(), false},
}
for i, v := range textTests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Expand All @@ -84,10 +84,10 @@ func TestPattern_At(t *testing.T) {
pattern *Pattern
expected bool
}{
{[]message.MessageSegment{message.Text("haha")}, NewPattern().At(), false},
{[]message.MessageSegment{message.Image("not a image")}, NewPattern().At(), false},
{[]message.MessageSegment{message.At(114514)}, NewPattern().At(), true},
{[]message.MessageSegment{message.At(114514)}, NewPattern().At("1919810"), false},
{[]message.Segment{message.Text("haha")}, NewPattern().At(), false},
{[]message.Segment{message.Image("not a image")}, NewPattern().At(), false},
{[]message.Segment{message.At(114514)}, NewPattern().At(), true},
{[]message.Segment{message.At(114514)}, NewPattern().At("1919810"), false},
}
for i, v := range textTests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Expand All @@ -105,12 +105,12 @@ func TestPattern_Reply(t *testing.T) {
pattern *Pattern
expected bool
}{
{[]message.MessageSegment{message.Text("haha")}, NewPattern().Reply(), false},
{[]message.MessageSegment{message.Image("not a image")}, NewPattern().Reply(), false},
{[]message.MessageSegment{message.At(1919810), message.Reply(12345)}, NewPattern().Reply().At(), false},
{[]message.MessageSegment{message.Reply(12345), message.At(1919810)}, NewPattern().Reply().At(), true},
{[]message.MessageSegment{message.Reply(12345)}, NewPattern().Reply(), true},
{[]message.MessageSegment{message.Reply(12345), message.At(1919810)}, NewPattern().Reply(), false},
{[]message.Segment{message.Text("haha")}, NewPattern().Reply(), false},
{[]message.Segment{message.Image("not a image")}, NewPattern().Reply(), false},
{[]message.Segment{message.At(1919810), message.Reply(12345)}, NewPattern().Reply().At(), false},
{[]message.Segment{message.Reply(12345), message.At(1919810)}, NewPattern().Reply().At(), true},
{[]message.Segment{message.Reply(12345)}, NewPattern().Reply(), true},
{[]message.Segment{message.Reply(12345), message.At(1919810)}, NewPattern().Reply(), false},
}
for i, v := range textTests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Expand All @@ -136,15 +136,15 @@ func TestPattern_SetOptional(t *testing.T) {
pattern *Pattern
expected []PatternParsed
}{
{[]message.MessageSegment{message.Text("/do it")}, NewPattern().Text("/(do) (.*)").At().SetOptional(true), []PatternParsed{
{[]message.Segment{message.Text("/do it")}, NewPattern().Text("/(do) (.*)").At().SetOptional(true), []PatternParsed{
{
Valid: true,
}, {
Valid: false,
},
}},
{[]message.MessageSegment{message.Text("/do it")}, NewPattern().Text("/(do) (.*)").At().SetOptional(false), []PatternParsed{}},
{[]message.MessageSegment{message.Text("happy bear"), message.At(114514)}, NewPattern().Reply().SetOptional().Text(".+").SetOptional().At().SetOptional(false), []PatternParsed{
{[]message.Segment{message.Text("/do it")}, NewPattern().Text("/(do) (.*)").At().SetOptional(false), []PatternParsed{}},
{[]message.Segment{message.Text("happy bear"), message.At(114514)}, NewPattern().Reply().SetOptional().Text(".+").SetOptional().At().SetOptional(false), []PatternParsed{
{
Valid: false,
},
Expand All @@ -155,7 +155,7 @@ func TestPattern_SetOptional(t *testing.T) {
Valid: true,
},
}},
{[]message.MessageSegment{message.Text("happy bear"), message.At(114514)}, NewPattern().Image().SetOptional().Image().SetOptional().Image().SetOptional(), []PatternParsed{ // why you do this
{[]message.Segment{message.Text("happy bear"), message.At(114514)}, NewPattern().Image().SetOptional().Image().SetOptional().Image().SetOptional(), []PatternParsed{ // why you do this
{
Valid: false,
},
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestAllParse(t *testing.T) {
pattern *Pattern
expected []PatternParsed
}{
{[]message.MessageSegment{message.Text("test haha test"), message.At(123)}, NewPattern().Text("((ha)+)").At(), []PatternParsed{
{[]message.Segment{message.Text("test haha test"), message.At(123)}, NewPattern().Text("((ha)+)").At(), []PatternParsed{
{
Valid: true,
Value: []string{"haha", "haha", "ha"},
Expand All @@ -205,13 +205,13 @@ func TestAllParse(t *testing.T) {
Value: "123",
},
}},
{[]message.MessageSegment{message.Text("haha")}, NewPattern().Text("(h)(a)(h)(a)"), []PatternParsed{
{[]message.Segment{message.Text("haha")}, NewPattern().Text("(h)(a)(h)(a)"), []PatternParsed{
{
Valid: true,
Value: []string{"haha", "h", "a", "h", "a"},
},
}},
{[]message.MessageSegment{message.Reply("fake reply"), message.Image("fake image"), message.At(999), message.At(124), message.Text("haha")}, NewPattern().Reply().Image().At().At("124").Text("(h)(a)(h)(a)"), []PatternParsed{
{[]message.Segment{message.Reply("fake reply"), message.Image("fake image"), message.At(999), message.At(124), message.Text("haha")}, NewPattern().Reply().Image().At().At("124").Text("(h)(a)(h)(a)"), []PatternParsed{

{
Valid: true,
Expand Down

0 comments on commit 0f30441

Please sign in to comment.