()
| 53 | } |
| 54 | |
| 55 | func (s *PoolTestSuite) SetupTest() { |
| 56 | adminCtx := auth.GetAdminContext(context.Background()) |
| 57 | |
| 58 | // create testing sqlite database |
| 59 | dbCfg := garmTesting.GetTestSqliteDBConfig(s.T()) |
| 60 | db, err := database.NewDatabase(adminCtx, dbCfg) |
| 61 | if err != nil { |
| 62 | s.FailNow(fmt.Sprintf("failed to create db connection: %s", err)) |
| 63 | } |
| 64 | |
| 65 | s.adminCtx = garmTesting.ImpersonateAdminContext(adminCtx, db, s.T()) |
| 66 | |
| 67 | s.githubEndpoint = garmTesting.CreateDefaultGithubEndpoint(s.adminCtx, db, s.T()) |
| 68 | s.testCreds = garmTesting.CreateTestGithubCredentials(s.adminCtx, "new-creds", db, s.T(), s.githubEndpoint) |
| 69 | s.secondaryTestCreds = garmTesting.CreateTestGithubCredentials(s.adminCtx, "secondary-creds", db, s.T(), s.githubEndpoint) |
| 70 | |
| 71 | // create an organization for testing purposes |
| 72 | org, err := db.CreateOrganization(s.adminCtx, "test-org", s.testCreds, "test-webhookSecret", params.PoolBalancerTypeRoundRobin, false) |
| 73 | if err != nil { |
| 74 | s.FailNow(fmt.Sprintf("failed to create org: %s", err)) |
| 75 | } |
| 76 | |
| 77 | // create some pool objects in the database, for testing purposes |
| 78 | entity := params.ForgeEntity{ |
| 79 | ID: org.ID, |
| 80 | EntityType: params.ForgeEntityTypeOrganization, |
| 81 | } |
| 82 | orgPools := []params.Pool{} |
| 83 | for i := 1; i <= 3; i++ { |
| 84 | pool, err := db.CreateEntityPool( |
| 85 | adminCtx, |
| 86 | entity, |
| 87 | params.CreatePoolParams{ |
| 88 | ProviderName: "test-provider", |
| 89 | MaxRunners: 4, |
| 90 | MinIdleRunners: 2, |
| 91 | Image: fmt.Sprintf("test-image-%d", i), |
| 92 | Flavor: "test-flavor", |
| 93 | OSType: "linux", |
| 94 | Tags: []string{"amd64-linux-runner"}, |
| 95 | RunnerBootstrapTimeout: 0, |
| 96 | }, |
| 97 | ) |
| 98 | if err != nil { |
| 99 | s.FailNow(fmt.Sprintf("cannot create org pool: %v", err)) |
| 100 | } |
| 101 | orgPools = append(orgPools, pool) |
| 102 | } |
| 103 | |
| 104 | // setup test fixtures |
| 105 | var maxRunners uint = 40 |
| 106 | var minIdleRunners uint = 20 |
| 107 | fixtures := &PoolTestFixtures{ |
| 108 | AdminContext: adminCtx, |
| 109 | Store: db, |
| 110 | Pools: orgPools, |
| 111 | UpdatePoolParams: params.UpdatePoolParams{ |
| 112 | MaxRunners: &maxRunners, |
nothing calls this directly
no test coverage detected