Add more unit tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
2b1414d150
commit
2a3d524a71
7 changed files with 516 additions and 39 deletions
|
|
@ -19,6 +19,7 @@ package testing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
|
@ -60,6 +61,30 @@ func ImpersonateAdminContext(ctx context.Context, db common.Store, s *testing.T)
|
|||
return ctx
|
||||
}
|
||||
|
||||
func CreateGARMTestUser(ctx context.Context, username string, db common.Store, s *testing.T) params.User {
|
||||
newUserParams := params.NewUserParams{
|
||||
Email: fmt.Sprintf("%s@localhost", username),
|
||||
Username: username,
|
||||
Password: "superSecretPassword@123",
|
||||
IsAdmin: false,
|
||||
Enabled: true,
|
||||
}
|
||||
|
||||
user, err := db.CreateUser(ctx, newUserParams)
|
||||
if err != nil {
|
||||
if errors.Is(err, runnerErrors.ErrDuplicateEntity) {
|
||||
user, err = db.GetUser(ctx, newUserParams.Username)
|
||||
if err != nil {
|
||||
s.Fatalf("failed to get user by email: %v", err)
|
||||
}
|
||||
return user
|
||||
}
|
||||
s.Fatalf("failed to create user: %v", err)
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func CreateDefaultGithubEndpoint(ctx context.Context, db common.Store, s *testing.T) params.GithubEndpoint {
|
||||
endpointParams := params.CreateGithubEndpointParams{
|
||||
Name: "github.com",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue