コード例 #1
0
func (suite *ListTracksCommandTestSuite) TestExecuteWithValidArg() {
	track1 := new(bot.Track)
	track1.Title = "first"
	track1.Submitter = "test"

	track2 := new(bot.Track)
	track2.Title = "second"
	track2.Submitter = "test"

	track3 := new(bot.Track)
	track3.Title = "third"
	track3.Submitter = "test"

	DJ.Queue.AppendTrack(track1)
	DJ.Queue.AppendTrack(track2)
	DJ.Queue.AppendTrack(track3)

	message, isPrivateMessage, err := suite.Command.Execute(nil, "2")

	suite.NotEqual("", message, "A message containing track information should be returned.")
	suite.Contains(message, "first", "The returned message should contain the first track.")
	suite.Contains(message, "second", "The returned message should contain the second track.")
	suite.NotContains(message, "third", "The returned message should not contain the third track.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #2
0
func (suite *NumTracksCommandTestSuite) TestExecuteWhenTwoOrMoreTracksAreInQueue() {
	track1 := new(bot.Track)
	track1.Title = "test"
	track1.Submitter = "test"

	track2 := new(bot.Track)
	track2.Title = "test"
	track2.Submitter = "test"

	DJ.Queue.AppendTrack(track1)
	DJ.Queue.AppendTrack(track2)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.NotEqual("", "A message should be returned.")
	suite.Contains(message, "tracks", "The returned message should use the plural form of the word track.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #3
0
func (suite *NextTrackCommandTestSuite) TestExecuteWhenQueueHasTwoOrMoreTracks() {
	track1 := new(bot.Track)
	track1.Title = "first"
	track1.Submitter = "test"

	track2 := new(bot.Track)
	track2.Title = "second"
	track2.Submitter = "test"

	DJ.Queue.AppendTrack(track1)
	DJ.Queue.AppendTrack(track2)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.NotEqual("", "A message containing information for the next track should be returned.")
	suite.Contains(message, "second", "The returned message should contain information about the second track in the queue.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #4
0
func (suite *CurrentTrackCommandTestSuite) TestExecuteWhenQueueNotEmpty() {
	track := new(bot.Track)
	track.Submitter = "test"
	track.Title = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.NotEqual("", message, "A message should be returned with the current track information.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #5
0
func (suite *ListTracksCommandTestSuite) TestExecuteWithInvalidArg() {
	track := new(bot.Track)
	track.Title = "track"
	track.Submitter = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil, "test")

	suite.Equal("", message, "No message should be returned.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.NotNil(err, "An error should be returned due to an invalid argument being supplied.")
}
コード例 #6
0
func (suite *NextTrackCommandTestSuite) TestExecuteWhenQueueHasOneTrack() {
	track := new(bot.Track)
	track.Title = "test"
	track.Submitter = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.Equal("", message, "No message should be returned.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.NotNil(err, "An error should be returned due to the queue having only one track.")
}
コード例 #7
0
func (suite *NumTracksCommandTestSuite) TestExecuteWhenOneTrackIsInQueue() {
	track := new(bot.Track)
	track.Title = "test"
	track.Submitter = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.NotEqual("", message, "A message should be returned.")
	suite.Contains(message, "<b>1</b> track", "The returned message should state that there is one track in the queue.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #8
0
func (suite *ListTracksCommandTestSuite) TestExecuteWithNoArg() {
	track := new(bot.Track)
	track.Title = "title"
	track.Submitter = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil)

	suite.NotEqual("", message, "A message containing track information should be returned.")
	suite.Contains(message, "title", "The returned message should contain the track title.")
	suite.Contains(message, "test", "The returned message should contain the track submitter.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}
コード例 #9
0
func (suite *ListTracksCommandTestSuite) TestExecuteWithArgLargerThanQueueLength() {
	track := new(bot.Track)
	track.Title = "track"
	track.Submitter = "test"

	DJ.Queue.AppendTrack(track)

	message, isPrivateMessage, err := suite.Command.Execute(nil, "2")

	suite.NotEqual("", message, "A message containing track information should be returned.")
	suite.Contains(message, "1", "The returned message should contain the first track.")
	suite.NotContains(message, "2", "The returned message should not contain any further tracks.")
	suite.True(isPrivateMessage, "This should be a private message.")
	suite.Nil(err, "No error should be returned.")
}