Exemple #1
0
func TestPuke(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("beers += 5"))
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 5, it.Count)
	b.Message(makeMessage("puke"))
	it, err = counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 0, it.Count)
}
Exemple #2
0
func TestEqNeg(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("!beers = -3"))
	assert.Len(t, mb.Messages, 1)
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 0, it.Count)
}
Exemple #3
0
func TestBourbon(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("bourbon++"))
	assert.Len(t, mb.Messages, 1)
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 2, it.Count)
}
Exemple #4
0
func TestBeersReport(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("beers += 5"))
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 5, it.Count)
	b.Message(makeMessage("beers"))
	assert.Contains(t, mb.Messages[1], "5 beers")
}
Exemple #5
0
func TestEqZero(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("beers += 5"))
	b.Message(makeMessage("!beers = 0"))
	assert.Len(t, mb.Messages, 2)
	assert.Contains(t, mb.Messages[1], "reversal of fortune")
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 0, it.Count)
}
Exemple #6
0
func TestBeersMinusMinus(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("beers = 5"))
	assert.Len(t, mb.Messages, 1)
	b.Message(makeMessage("beers--"))
	assert.Len(t, mb.Actions, 1)
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 4, it.Count)
}
Exemple #7
0
func TestBeersPlusEq(t *testing.T) {
	b, mb := makeBeersPlugin(t)
	b.Message(makeMessage("beers += 5"))
	assert.Len(t, mb.Messages, 1)
	b.Message(makeMessage("beers += 5"))
	assert.Len(t, mb.Messages, 2)
	it, err := counter.GetItem(mb.DB(), "tester", "booze")
	assert.Nil(t, err)
	assert.Equal(t, 10, it.Count)
}
Exemple #8
0
func getUserBeers(db *sqlx.DB, user string) counter.Item {
	booze, _ := counter.GetItem(db, user, "booze")
	return booze
}