Example #1
0
func TestDoActionArgsUser(t *testing.T) {
	p := lgtm.NewPlugin()

	testEvent := plugins.NewTestEvent("LGTM kyokomi")
	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
		t.Errorf("ERROR next != false")
	}
}
Example #2
0
func TestSysstdBuildPluginsHelp(t *testing.T) {
	botCtx, err := slackbot.NewBotContext("hoge_token")
	if err != nil {
		t.Error(err)
	}
	botCtx.AddPlugin("echo", echo.NewPlugin())
	p := sysstd.NewPlugin(botCtx.PluginManager())

	ev := plugins.NewTestEvent("botID help")
	p.DoAction(ev, "help")
}
Example #3
0
package docomo_test

import (
	"testing"

	"github.com/kyokomi/slackbot"
	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/docomo"
)

var testEvent = plugins.NewTestEvent("botID こんにちわ")

func TestCheckMessage(t *testing.T) {
	p := docomo.NewPlugin(nil, slackbot.NewOnMemoryRepository())
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

// TODO: docomo.ClientのMockが必要
//func TestDoAction(t *testing.T) {
//	p := docomo.Plugin{}
//
//	next := p.DoAction(testEvent, testEvent.BaseText())
//
//	if next != true {
//		t.Errorf("ERROR next != true")
//	}
//}
Example #4
0
package cron_test

import (
	"fmt"
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/cron"
)

var testEvents = []plugins.BotEvent{
	plugins.NewTestEvent("cron add */1 * * * * * hogehoge"),
	plugins.NewTestEvent("cron list"),
	plugins.NewTestEvent("cron help"),
	plugins.NewTestEvent("cron del xfjield"),
}

func TestCheckMessage(t *testing.T) {
	repository := cron.NewOnMemoryCronRepository()
	p := cron.NewPlugin(cron.NewCronContext(repository))
	for _, testEvent := range testEvents {
		ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
		if !ok {
			t.Errorf("ERROR check = NG")
		}
	}
}

func TestDoAction(t *testing.T) {
	repository := cron.NewOnMemoryCronRepository()
	p := cron.NewPlugin(cron.NewCronContext(repository))
Example #5
0
package akari_test

import (
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/akari"
)

var testEvent = plugins.NewTestEvent("test大好き")

func TestCheckMessage(t *testing.T) {
	p := akari.NewPlugin()
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := akari.NewPlugin()

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
		t.Errorf("ERROR next != false")
	}
}
Example #6
0
package echo_test

import (
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/echo"
)

var testEvent = plugins.NewTestEvent("てすと")

func TestCheckMessage(t *testing.T) {
	p := echo.NewPlugin()
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := echo.NewPlugin()

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != true {
		t.Errorf("ERROR next != true")
	}
}
Example #7
0
package kohaimage_test

import (
	"testing"

	"github.com/golang/mock/gomock"
	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/kohaimage"
)

var testEvent = plugins.NewTestEvent("koha")

func TestCheckMessage(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	p := kohaimage.NewPlugin(nil)

	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	mockAPI := kohaimage.NewMockKohaAPI(ctrl)
	mockAPI.EXPECT().GetImageURL().Return("http://pbs.twimg.com/media/CQJLPe7UAAAH20f.png")
	p := kohaimage.NewPlugin(mockAPI)
Example #8
0
package lgtm_test

import (
	"testing"

	"fmt"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/lgtm"
)

var testEvent = plugins.NewTestEvent("LGTM")

func TestCheckMessage(t *testing.T) {
	p := lgtm.NewPlugin()
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := lgtm.NewPlugin()

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
		t.Errorf("ERROR next != false")
	}
}
Example #9
0
package googleimage_test

import (
	"log"
	"net/http"
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/googleimage"
)

var testEvent = plugins.NewTestEvent("image me hoge")

func init() {
	log.SetFlags(log.Llongfile)
}

func TestCheckMessage(t *testing.T) {
	p := googleimage.NewPlugin(googleimage.NewGoogleImageAPIClient(http.DefaultClient, "cx", "key"))
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := googleimage.NewPlugin(googleimage.NewGoogleImageAPIClient(http.DefaultClient, "cx", "key"))

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
Example #10
0
package sysstd_test

import (
	"fmt"
	"testing"

	"github.com/kyokomi/slackbot"
	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/echo"
	"github.com/kyokomi/slackbot/plugins/sysstd"
)

var testEvent = plugins.NewTestEvent("botID date tokyo")

func TestCheckMessage(t *testing.T) {
	p := sysstd.NewPlugin(nil)
	ok, message := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	} else {
		fmt.Println(message)
	}
}

func TestDoAction(t *testing.T) {
	p := sysstd.NewPlugin(nil)

	next := p.DoAction(testEvent, "date a 1 3")

	if next != false {
		t.Errorf("ERROR next != false")
Example #11
0
package suddendeath_test

import (
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/suddendeath"
)

var testEvent = plugins.NewTestEvent("突然の死だああああああああああ!")

func TestCheckMessage(t *testing.T) {
	p := suddendeath.NewPlugin()
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := suddendeath.NewPlugin()

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
		t.Errorf("ERROR next != false")
	}
}
Example #12
0
package naruhodo_test

import (
	"testing"

	"github.com/kyokomi/slackbot/plugins"
	"github.com/kyokomi/slackbot/plugins/naruhodo"
)

var testEvent = plugins.NewTestEvent("それは、なるほど")

func TestCheckMessage(t *testing.T) {
	p := naruhodo.NewPlugin()
	ok, _ := p.CheckMessage(testEvent, testEvent.BaseText())
	if !ok {
		t.Errorf("ERROR check = NG")
	}
}

func TestDoAction(t *testing.T) {
	p := naruhodo.NewPlugin()

	next := p.DoAction(testEvent, testEvent.BaseText())

	if next != false {
		t.Errorf("ERROR next != false")
	}
}