You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: message_test.go
    path of file: ./repos/server/database
    
    the code of the file until where you have to start completion: package database

import (
	"testing"
	"time"

	"github.com/gotify/server/v2/model"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func (s *DatabaseSuite) TestMessage() {
	messages, err := s.db.GetMessageByID(5)
	require.NoError(s.T(), err)
	assert.Nil(s.T(), messages, "not existing message")

	user := &model.User{Name: "test", Pass: []byte{1}}
	s.db.CreateUser(user)
	assert.NotEqual(s.T(), 0, user.ID)

	backupServer := &model.Application{UserID: user.ID, Token: "A0000000000", Name: "backupserver"}
	s.db.CreateApplication(backupServer)
	assert.NotEqual(s.T(), 0, backupServer.ID)

	msgs, err := s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	backupdone := &model.Message{ApplicationID: backupServer.ID, Message: "backup done", Title: "backup", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(backupdone))
	assert.NotEqual(s.T(), 0, backupdone.ID)

	messages, err = s.db.GetMessageByID(backupdone.ID)
	require.NoError(s.T(), err)
	assertEquals(s.T(), messages, backupdone)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	loginServer := &model.Application{UserID: user.ID, Token: "A0000000001", Name: "loginserver"}
	require.NoError(s.T(), s.db.CreateApplication(loginServer))
	assert.NotEqual(s.T(), 0, loginServer.ID)

	logindone := &model.Message{ApplicationID: loginServer.ID, Message: "login done", Title: "login", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(logindone))
	assert.NotEqual(s.T(), 0, logindone.ID)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], logindone)
	assertEquals(s.T(), msgs[1], backupdone)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	loginfailed := &model.Message{ApplicationID: loginServer.ID, Message: "login failed", Title: "login", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(loginfailed))
	assert.NotEqual(s.T(), 0, loginfailed.ID)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	msgs, err = s.db.GetMessagesByApplication(loginServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], loginfailed)
	assertEquals(s.T(), msgs[1], logindone)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 3)
	assertEquals(s.T(), msgs[0], loginfailed)
	assertEquals(s.T(), msgs[1], logindone)
	assertEquals(s.T(), msgs[2], backupdone)

	backupfailed := &model.Message{
    
func (s *DatabaseSuite) TestMessage() {
	messages, err := s.db.GetMessageByID(5)
	require.NoError(s.T(), err)
	assert.Nil(s.T(), messages, "not existing message")

	user := &model.User{Name: "test", Pass: []byte{1}}
	s.db.CreateUser(user)
	assert.NotEqual(s.T(), 0, user.ID)

	backupServer := &model.Application{UserID: user.ID, Token: "A0000000000", Name: "backupserver"}
	s.db.CreateApplication(backupServer)
	assert.NotEqual(s.T(), 0, backupServer.ID)

	msgs, err := s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	backupdone := &model.Message{ApplicationID: backupServer.ID, Message: "backup done", Title: "backup", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(backupdone))
	assert.NotEqual(s.T(), 0, backupdone.ID)

	messages, err = s.db.GetMessageByID(backupdone.ID)
	require.NoError(s.T(), err)
	assertEquals(s.T(), messages, backupdone)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	loginServer := &model.Application{UserID: user.ID, Token: "A0000000001", Name: "loginserver"}
	require.NoError(s.T(), s.db.CreateApplication(loginServer))
	assert.NotEqual(s.T(), 0, loginServer.ID)

	logindone := &model.Message{ApplicationID: loginServer.ID, Message: "login done", Title: "login", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(logindone))
	assert.NotEqual(s.T(), 0, logindone.ID)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], logindone)
	assertEquals(s.T(), msgs[1], backupdone)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	loginfailed := &model.Message{ApplicationID: loginServer.ID, Message: "login failed", Title: "login", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(loginfailed))
	assert.NotEqual(s.T(), 0, loginfailed.ID)

	msgs, err = s.db.GetMessagesByApplication(backupServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], backupdone)

	msgs, err = s.db.GetMessagesByApplication(loginServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], loginfailed)
	assertEquals(s.T(), msgs[1], logindone)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 3)
	assertEquals(s.T(), msgs[0], loginfailed)
	assertEquals(s.T(), msgs[1], logindone)
	assertEquals(s.T(), msgs[2], backupdone)

	backupfailed := &model.Message{ApplicationID: backupServer.ID, Message: "backup failed", Title: "backup", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(backupfailed))
	assert.NotEqual(s.T(), 0, backupfailed.ID)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 4)
	assertEquals(s.T(), msgs[0], backupfailed)
	assertEquals(s.T(), msgs[1], loginfailed)
	assertEquals(s.T(), msgs[2], logindone)
	assertEquals(s.T(), msgs[3], backupdone)

	msgs, err = s.db.GetMessagesByApplication(loginServer.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], loginfailed)
	assertEquals(s.T(), msgs[1], logindone)

	require.NoError(s.T(), s.db.DeleteMessagesByApplication(loginServer.ID))
	msgs, err = s.db.GetMessagesByApplication(loginServer.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 2)
	assertEquals(s.T(), msgs[0], backupfailed)
	assertEquals(s.T(), msgs[1], backupdone)

	logindone = &model.Message{ApplicationID: loginServer.ID, Message: "login done", Title: "login", Priority: 1, Date: time.Now()}
	require.NoError(s.T(), s.db.CreateMessage(logindone))
	assert.NotEqual(s.T(), 0, logindone.ID)

	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 3)
	assertEquals(s.T(), msgs[0], logindone)
	assertEquals(s.T(), msgs[1], backupfailed)
	assertEquals(s.T(), msgs[2], backupdone)

	s.db.DeleteMessagesByUser(user.ID)
	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)

	logout := &model.Message{ApplicationID: loginServer.ID, Message: "logout success", Title: "logout", Priority: 1, Date: time.Now()}
	s.db.CreateMessage(logout)
	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Len(s.T(), msgs, 1)
	assertEquals(s.T(), msgs[0], logout)

	require.NoError(s.T(), s.db.DeleteMessageByID(logout.ID))
	msgs, err = s.db.GetMessagesByUser(user.ID)
	require.NoError(s.T(), err)
	assert.Empty(s.T(), msgs)
}