()
| 64 | } |
| 65 | |
| 66 | func (s *OrgTestSuite) SetupTest() { |
| 67 | // create testing sqlite database |
| 68 | dbCfg := garmTesting.GetTestSqliteDBConfig(s.T()) |
| 69 | db, err := database.NewDatabase(context.Background(), dbCfg) |
| 70 | if err != nil { |
| 71 | s.FailNow(fmt.Sprintf("failed to create db connection: %s", err)) |
| 72 | } |
| 73 | |
| 74 | adminCtx := garmTesting.ImpersonateAdminContext(context.Background(), db, s.T()) |
| 75 | |
| 76 | s.githubEndpoint = garmTesting.CreateDefaultGithubEndpoint(adminCtx, db, s.T()) |
| 77 | s.giteaEndpoint = garmTesting.CreateDefaultGiteaEndpoint(adminCtx, db, s.T()) |
| 78 | s.testCreds = garmTesting.CreateTestGithubCredentials(adminCtx, "new-creds", db, s.T(), s.githubEndpoint) |
| 79 | s.giteaTestCreds = garmTesting.CreateTestGiteaCredentials(adminCtx, "gitea-creds", db, s.T(), s.giteaEndpoint) |
| 80 | s.secondaryTestCreds = garmTesting.CreateTestGithubCredentials(adminCtx, "secondary-creds", db, s.T(), s.githubEndpoint) |
| 81 | |
| 82 | // create some organization objects in the database, for testing purposes |
| 83 | orgs := map[string]params.Organization{} |
| 84 | for i := 1; i <= 3; i++ { |
| 85 | name := fmt.Sprintf("test-org-%v", i) |
| 86 | org, err := db.CreateOrganization( |
| 87 | adminCtx, |
| 88 | name, |
| 89 | s.testCreds, |
| 90 | fmt.Sprintf("test-webhook-secret-%v", i), |
| 91 | params.PoolBalancerTypeRoundRobin, |
| 92 | false, |
| 93 | ) |
| 94 | if err != nil { |
| 95 | s.FailNow(fmt.Sprintf("failed to create database object (test-org-%v)", i)) |
| 96 | } |
| 97 | orgs[name] = org |
| 98 | } |
| 99 | |
| 100 | // setup test fixtures |
| 101 | var maxRunners uint = 40 |
| 102 | var minIdleRunners uint = 20 |
| 103 | providerMock := runnerCommonMocks.NewProvider(s.T()) |
| 104 | fixtures := &OrgTestFixtures{ |
| 105 | AdminContext: adminCtx, |
| 106 | DBFile: dbCfg.SQLite.DBFile, |
| 107 | Store: db, |
| 108 | StoreOrgs: orgs, |
| 109 | Providers: map[string]common.Provider{ |
| 110 | "test-provider": providerMock, |
| 111 | }, |
| 112 | Credentials: map[string]params.ForgeCredentials{ |
| 113 | s.testCreds.Name: s.testCreds, |
| 114 | s.secondaryTestCreds.Name: s.secondaryTestCreds, |
| 115 | }, |
| 116 | CreateOrgParams: params.CreateOrgParams{ |
| 117 | Name: "test-org-create", |
| 118 | CredentialsName: s.testCreds.Name, |
| 119 | WebhookSecret: "test-create-org-webhook-secret", |
| 120 | }, |
| 121 | CreatePoolParams: params.CreatePoolParams{ |
| 122 | ProviderName: "test-provider", |
| 123 | MaxRunners: 4, |
nothing calls this directly
no test coverage detected