cli: finish removing references from tests

This commit is contained in:
Chris Sexton 2024-02-27 17:28:02 -05:00
parent a5e919733c
commit b20da607bc
17 changed files with 14 additions and 54 deletions

View File

@ -5,8 +5,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -34,10 +32,8 @@ func makeMessage(payload string, r *regexp.Regexp) bot.Request {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
c := cli.CliPlugin{}
values := bot.ParseValues(r, payload) values := bot.ParseValues(r, payload)
return bot.Request{ return bot.Request{
Conn: &c,
Kind: bot.Message, Kind: bot.Message,
Values: values, Values: values,
Msg: msg.Message{ Msg: msg.Message{

View File

@ -7,8 +7,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -16,13 +14,11 @@ import (
) )
func makeMessage(payload string, r *regexp.Regexp) bot.Request { func makeMessage(payload string, r *regexp.Regexp) bot.Request {
c := &cli.CliPlugin{}
isCmd := strings.HasPrefix(payload, "!") isCmd := strings.HasPrefix(payload, "!")
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return bot.Request{ return bot.Request{
Conn: c,
Kind: bot.Message, Kind: bot.Message,
Values: bot.ParseValues(r, payload), Values: bot.ParseValues(r, payload),
Msg: msg.Message{ Msg: msg.Message{
@ -272,7 +268,6 @@ func TestHelp(t *testing.T) {
mb := bot.NewMockBot() mb := bot.NewMockBot()
bp := newBabblerPlugin(mb) bp := newBabblerPlugin(mb)
assert.NotNil(t, bp) assert.NotNil(t, bp)
c := &cli.CliPlugin{} bp.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
bp.help(c, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Len(t, mb.Messages, 1) assert.Len(t, mb.Messages, 1)
} }

View File

@ -7,8 +7,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -21,10 +19,8 @@ func makeMessage(payload string, r *regexp.Regexp) bot.Request {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
c := &cli.CliPlugin{}
values := bot.ParseValues(r, payload) values := bot.ParseValues(r, payload)
return bot.Request{ return bot.Request{
Conn: c,
Kind: bot.Message, Kind: bot.Message,
Values: values, Values: values,
Msg: msg.Message{ Msg: msg.Message{
@ -136,6 +132,6 @@ func TestBeersReport(t *testing.T) {
func TestHelp(t *testing.T) { func TestHelp(t *testing.T) {
b, mb := makeBeersPlugin(t) b, mb := makeBeersPlugin(t)
b.help(&cli.CliPlugin{}, bot.Help, msg.Message{Channel: "channel"}, []string{}) b.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Len(t, mb.Messages, 1) assert.Len(t, mb.Messages, 1)
} }

View File

@ -6,8 +6,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
@ -21,7 +19,6 @@ func makeMessage(payload string) bot.Request {
payload = payload[1:] payload = payload[1:]
} }
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},

View File

@ -4,12 +4,12 @@ package counter
import ( import (
"fmt" "fmt"
"github.com/velour/catbase/config"
"github.com/velour/catbase/connectors/irc"
"regexp" "regexp"
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
@ -33,7 +33,7 @@ func makeMessage(payload string, r *regexp.Regexp) bot.Request {
} }
values := bot.ParseValues(r, payload) values := bot.ParseValues(r, payload)
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{}, Conn: irc.New(&config.Config{}),
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: "tester", ID: "id"}, User: &user.User{Name: "tester", ID: "id"},
Body: payload, Body: payload,
@ -280,6 +280,6 @@ func TestInspectMe(t *testing.T) {
func TestHelp(t *testing.T) { func TestHelp(t *testing.T) {
mb, c := setup(t) mb, c := setup(t)
assert.NotNil(t, c) assert.NotNil(t, c)
c.help(&cli.CliPlugin{}, bot.Help, msg.Message{Channel: "channel"}, []string{}) c.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Greater(t, len(mb.Messages), 1) assert.Greater(t, len(mb.Messages), 1)
} }

View File

@ -6,8 +6,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -21,7 +19,6 @@ func makeMessage(payload string) bot.Request {
} }
values := bot.ParseValues(rollRegex, payload) values := bot.ParseValues(rollRegex, payload)
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Values: values, Values: values,
Msg: msg.Message{ Msg: msg.Message{
@ -67,6 +64,6 @@ func TestHelp(t *testing.T) {
mb := bot.NewMockBot() mb := bot.NewMockBot()
c := New(mb) c := New(mb)
assert.NotNil(t, c) assert.NotNil(t, c)
c.help(&cli.CliPlugin{}, bot.Help, msg.Message{Channel: "channel"}, []string{}) c.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Len(t, mb.Messages, 1) assert.Len(t, mb.Messages, 1)
} }

View File

@ -5,8 +5,6 @@ package leftpad
import ( import (
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -18,7 +16,6 @@ func makeMessage(payload string) bot.Request {
values := bot.ParseValues(leftpadRegex, payload) values := bot.ParseValues(leftpadRegex, payload)
return bot.Request{ return bot.Request{
Kind: bot.Message, Kind: bot.Message,
Conn: &cli.CliPlugin{},
Values: values, Values: values,
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},

View File

@ -12,8 +12,6 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
@ -45,7 +43,6 @@ func makeMessage(payload string) bot.Request {
payload = payload[1:] payload = payload[1:]
} }
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},

View File

@ -12,7 +12,6 @@ import (
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
"github.com/velour/catbase/bot/user" "github.com/velour/catbase/bot/user"
"github.com/velour/catbase/plugins/cli"
) )
func makeMessage(payload string) bot.Request { func makeMessage(payload string) bot.Request {
@ -22,7 +21,6 @@ func makeMessage(payload string) bot.Request {
} }
values := bot.ParseValues(pickRegex, payload) values := bot.ParseValues(pickRegex, payload)
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Values: values, Values: values,
Msg: msg.Message{ Msg: msg.Message{

View File

@ -5,8 +5,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -20,7 +18,6 @@ func makeMessage(nick, payload string, r *regexp.Regexp) bot.Request {
payload = payload[1:] payload = payload[1:]
} }
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Values: bot.ParseValues(r, payload), Values: bot.ParseValues(r, payload),
Msg: msg.Message{ Msg: msg.Message{

View File

@ -4,7 +4,6 @@ package reminder
import ( import (
"fmt" "fmt"
"github.com/velour/catbase/plugins/cli"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -24,7 +23,7 @@ func makeMessageBy(payload, by string) (bot.Connector, bot.Kind, msg.Message) {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return &cli.CliPlugin{}, bot.Message, msg.Message{ return nil, bot.Message, msg.Message{
User: &user.User{Name: by}, User: &user.User{Name: by},
Channel: "test", Channel: "test",
Body: payload, Body: payload,
@ -224,6 +223,6 @@ func TestLimitList(t *testing.T) {
func TestHelp(t *testing.T) { func TestHelp(t *testing.T) {
c, mb := setup(t) c, mb := setup(t)
assert.NotNil(t, c) assert.NotNil(t, c)
c.help(&cli.CliPlugin{}, bot.Help, msg.Message{Channel: "channel"}, []string{}) c.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Len(t, mb.Messages, 1) assert.Len(t, mb.Messages, 1)
} }

View File

@ -2,7 +2,6 @@ package rss
import ( import (
"fmt" "fmt"
"github.com/velour/catbase/plugins/cli"
"strings" "strings"
"testing" "testing"
@ -17,7 +16,7 @@ func makeMessage(payload string) (bot.Connector, bot.Kind, msg.Message) {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return &cli.CliPlugin{}, bot.Message, msg.Message{ return nil, bot.Message, msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},
Channel: "test", Channel: "test",
Body: payload, Body: payload,

View File

@ -1,7 +1,6 @@
package stock package stock
import ( import (
"github.com/velour/catbase/plugins/cli"
"strings" "strings"
"testing" "testing"
@ -16,7 +15,7 @@ func makeMessage(payload string) (bot.Connector, bot.Kind, msg.Message) {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return &cli.CliPlugin{}, bot.Message, msg.Message{ return nil, bot.Message, msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},
Channel: "test", Channel: "test",
Body: payload, Body: payload,

View File

@ -3,7 +3,6 @@
package talker package talker
import ( import (
"github.com/velour/catbase/plugins/cli"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func makeMessage(payload string) (bot.Connector, bot.Kind, msg.Message) {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return &cli.CliPlugin{}, bot.Message, msg.Message{ return nil, bot.Message, msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},
Channel: "test", Channel: "test",
Body: payload, Body: payload,
@ -79,6 +78,6 @@ func TestHelp(t *testing.T) {
mb := bot.NewMockBot() mb := bot.NewMockBot()
c := New(mb) c := New(mb)
assert.NotNil(t, c) assert.NotNil(t, c)
c.help(&cli.CliPlugin{}, bot.Help, msg.Message{Channel: "channel"}, []string{}) c.help(nil, bot.Help, msg.Message{Channel: "channel"}, []string{})
assert.Len(t, mb.Messages, 1) assert.Len(t, mb.Messages, 1)
} }

View File

@ -1,7 +1,6 @@
package tldr package tldr
import ( import (
"github.com/velour/catbase/plugins/cli"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@ -29,7 +28,6 @@ func makeMessageBy(payload, by string) bot.Request {
} }
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: by}, User: &user.User{Name: by},

View File

@ -3,7 +3,6 @@
package twitch package twitch
import ( import (
"github.com/velour/catbase/plugins/cli"
"strings" "strings"
"testing" "testing"
@ -29,7 +28,7 @@ func makeMessage(payload string) (bot.Connector, bot.Kind, msg.Message) {
if isCmd { if isCmd {
payload = payload[1:] payload = payload[1:]
} }
return &cli.CliPlugin{}, bot.Message, msg.Message{ return nil, bot.Message, msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},
Channel: "test", Channel: "test",
Body: payload, Body: payload,

View File

@ -6,8 +6,6 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot" "github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg" "github.com/velour/catbase/bot/msg"
@ -20,7 +18,6 @@ func makeMessage(payload string) bot.Request {
payload = payload[1:] payload = payload[1:]
} }
return bot.Request{ return bot.Request{
Conn: &cli.CliPlugin{},
Kind: bot.Message, Kind: bot.Message,
Msg: msg.Message{ Msg: msg.Message{
User: &user.User{Name: "tester"}, User: &user.User{Name: "tester"},