From 0f30441b123475ffeb547eafff7869301f093518 Mon Sep 17 00:00:00 2001 From: RikaCelery Date: Sun, 13 Oct 2024 00:36:12 +0800 Subject: [PATCH] chore: make lint happy --- pattern_test.go | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/pattern_test.go b/pattern_test.go index 4423ccc..4c5e35e 100644 --- a/pattern_test.go +++ b/pattern_test.go @@ -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{}, @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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, }, @@ -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, }, @@ -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"}, @@ -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,