Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
b2d5609352
commit
f0753eeb22
14 changed files with 1060 additions and 54 deletions
|
|
@ -110,6 +110,30 @@ func CreateDefaultGithubEndpoint(ctx context.Context, db common.Store, s *testin
|
|||
return ep
|
||||
}
|
||||
|
||||
func CreateDefaultGiteaEndpoint(ctx context.Context, db common.Store, s *testing.T) params.ForgeEndpoint {
|
||||
endpointParams := params.CreateGiteaEndpointParams{
|
||||
Name: "gitea.example.com",
|
||||
Description: "gitea endpoint",
|
||||
APIBaseURL: "https://gitea.example.com/",
|
||||
BaseURL: "https://gitea.example.com/",
|
||||
}
|
||||
|
||||
ep, err := db.GetGithubEndpoint(ctx, endpointParams.Name)
|
||||
if err != nil {
|
||||
if !errors.Is(err, runnerErrors.ErrNotFound) {
|
||||
s.Fatalf("failed to get database object (github.com): %v", err)
|
||||
}
|
||||
ep, err = db.CreateGiteaEndpoint(ctx, endpointParams)
|
||||
if err != nil {
|
||||
if !errors.Is(err, runnerErrors.ErrDuplicateEntity) {
|
||||
s.Fatalf("failed to create database object (github.com): %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ep
|
||||
}
|
||||
|
||||
func CreateTestGithubCredentials(ctx context.Context, credsName string, db common.Store, s *testing.T, endpoint params.ForgeEndpoint) params.ForgeCredentials {
|
||||
newCredsParams := params.CreateGithubCredentialsParams{
|
||||
Name: credsName,
|
||||
|
|
@ -127,6 +151,23 @@ func CreateTestGithubCredentials(ctx context.Context, credsName string, db commo
|
|||
return newCreds
|
||||
}
|
||||
|
||||
func CreateTestGiteaCredentials(ctx context.Context, credsName string, db common.Store, s *testing.T, endpoint params.ForgeEndpoint) params.ForgeCredentials {
|
||||
newCredsParams := params.CreateGiteaCredentialsParams{
|
||||
Name: credsName,
|
||||
Description: "Test creds",
|
||||
AuthType: params.ForgeAuthTypePAT,
|
||||
Endpoint: endpoint.Name,
|
||||
PAT: params.GithubPAT{
|
||||
OAuth2Token: "test-token",
|
||||
},
|
||||
}
|
||||
newCreds, err := db.CreateGiteaCredentials(ctx, newCredsParams)
|
||||
if err != nil {
|
||||
s.Fatalf("failed to create database object (%s): %v", credsName, err)
|
||||
}
|
||||
return newCreds
|
||||
}
|
||||
|
||||
func GetTestSqliteDBConfig(t *testing.T) config.Database {
|
||||
dir, err := os.MkdirTemp("", "garm-config-test")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue