()
| 79 | } |
| 80 | |
| 81 | func (s *MetadataTestSuite) SetupTest() { |
| 82 | // create testing sqlite database |
| 83 | dbCfg := garmTesting.GetTestSqliteDBConfig(s.T()) |
| 84 | db, err := database.NewDatabase(context.Background(), dbCfg) |
| 85 | if err != nil { |
| 86 | s.FailNow(fmt.Sprintf("failed to create db connection: %s", err)) |
| 87 | } |
| 88 | |
| 89 | s.adminCtx = garmTesting.ImpersonateAdminContext(context.Background(), db, s.T()) |
| 90 | |
| 91 | s.githubEndpoint = garmTesting.CreateDefaultGithubEndpoint(s.adminCtx, db, s.T()) |
| 92 | testCreds := garmTesting.CreateTestGithubCredentials(s.adminCtx, "test-creds", db, s.T(), s.githubEndpoint) |
| 93 | |
| 94 | // Create test organization |
| 95 | org, err := db.CreateOrganization(s.adminCtx, "test-org", testCreds, "test-webhook-secret", params.PoolBalancerTypeRoundRobin, false) |
| 96 | if err != nil { |
| 97 | s.FailNow(fmt.Sprintf("failed to create test org: %s", err)) |
| 98 | } |
| 99 | |
| 100 | entity, err := org.GetEntity() |
| 101 | if err != nil { |
| 102 | s.FailNow(fmt.Sprintf("failed to get entity: %s", err)) |
| 103 | } |
| 104 | // Set entity name for service name generation |
| 105 | entity.Name = "test-org" |
| 106 | |
| 107 | // Create test template |
| 108 | template, err := db.CreateTemplate(s.adminCtx, params.CreateTemplateParams{ |
| 109 | Name: "test-template", |
| 110 | Description: "Test template for metadata tests", |
| 111 | OSType: commonParams.Linux, |
| 112 | ForgeType: params.GithubEndpointType, |
| 113 | Data: []byte(`#!/bin/bash\necho "Installing runner..."`), |
| 114 | }) |
| 115 | if err != nil { |
| 116 | s.FailNow(fmt.Sprintf("failed to create test template: %s", err)) |
| 117 | } |
| 118 | |
| 119 | // Create test pool |
| 120 | pool, err := db.CreateEntityPool(s.adminCtx, entity, params.CreatePoolParams{ |
| 121 | ProviderName: "test-provider", |
| 122 | MaxRunners: 2, |
| 123 | MinIdleRunners: 1, |
| 124 | Image: "ubuntu:22.04", |
| 125 | Flavor: "medium", |
| 126 | OSType: commonParams.Linux, |
| 127 | OSArch: commonParams.Amd64, |
| 128 | Tags: []string{"linux", "amd64"}, |
| 129 | RunnerBootstrapTimeout: 10, |
| 130 | TemplateID: &template.ID, |
| 131 | }) |
| 132 | if err != nil { |
| 133 | s.FailNow(fmt.Sprintf("failed to create test pool: %s", err)) |
| 134 | } |
| 135 | |
| 136 | // Create test instance |
| 137 | instance, err := db.CreateInstance(s.adminCtx, pool.ID, params.CreateInstanceParams{ |
| 138 | Name: "test-instance", |
nothing calls this directly
no test coverage detected