mirror of
https://github.com/pushbits/server.git
synced 2025-08-02 08:09:00 +02:00
getApplication testing
This commit is contained in:
parent
ef5409eb35
commit
46dd19b07d
3 changed files with 94 additions and 1 deletions
32
tests/mockups/application.go
Normal file
32
tests/mockups/application.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package mockups
|
||||
|
||||
import "github.com/pushbits/server/internal/model"
|
||||
|
||||
// GetApplication1 returns an application with id 1
|
||||
func GetApplication1() *model.Application {
|
||||
return &model.Application{
|
||||
ID: 1,
|
||||
Token: "1234567890abcdefghijklmn",
|
||||
UserID: 1,
|
||||
Name: "App1",
|
||||
}
|
||||
}
|
||||
|
||||
// GetApplication2 returns an application with id 2
|
||||
func GetApplication2() *model.Application {
|
||||
return &model.Application{
|
||||
ID: 2,
|
||||
Token: "0987654321xyzabcdefghij",
|
||||
UserID: 1,
|
||||
Name: "App2",
|
||||
}
|
||||
}
|
||||
|
||||
// GetAllApplications returns all mock-applications as a list
|
||||
func GetAllApplications() []*model.Application {
|
||||
applications := make([]*model.Application, 0)
|
||||
applications = append(applications, GetApplication1())
|
||||
applications = append(applications, GetApplication2())
|
||||
|
||||
return applications
|
||||
}
|
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/pushbits/server/internal/authentication/credentials"
|
||||
"github.com/pushbits/server/internal/configuration"
|
||||
"github.com/pushbits/server/internal/database"
|
||||
"github.com/pushbits/server/internal/model"
|
||||
)
|
||||
|
||||
// GetEmptyDatabase returns an empty sqlite database object
|
||||
|
@ -11,3 +12,15 @@ func GetEmptyDatabase() (*database.Database, error) {
|
|||
cm := credentials.CreateManager(false, configuration.CryptoConfig{})
|
||||
return database.Create(cm, "sqlite3", "pushbits-test.db")
|
||||
}
|
||||
|
||||
// AddApplicationsToDb inserts the applications apps into the database db
|
||||
func AddApplicationsToDb(db *database.Database, apps []*model.Application) error {
|
||||
for _, app := range apps {
|
||||
err := db.CreateApplication(app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue