Skip to content

Commit 0ff3f9e

Browse files
committed
migrations & fix tests
1 parent be43729 commit 0ff3f9e

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

backend/controllers/github_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ func setupSuite(tb testing.TB) (func(tb testing.TB), *models.Database) {
591591
// migrate tables
592592
err = gdb.AutoMigrate(&models.Policy{}, &models.Organisation{}, &models.Repo{}, &models.Project{}, &models.Token{},
593593
&models.User{}, &models.ProjectRun{}, &models.GithubAppInstallation{}, &models.GithubApp{}, &models.GithubAppInstallationLink{},
594-
&models.GithubDiggerJobLink{}, &models.DiggerJob{}, &models.DiggerJobParentLink{})
594+
&models.GithubDiggerJobLink{}, &models.DiggerJob{}, &models.DiggerJobParentLink{}, &models.JobToken{})
595595
if err != nil {
596596
log.Fatal(err)
597597
}
@@ -732,7 +732,7 @@ func TestJobsTreeWithOneJobsAndTwoProjects(t *testing.T) {
732732
graph, err := configuration.CreateProjectDependencyGraph(projects)
733733
assert.NoError(t, err)
734734

735-
_, result, err := utils.ConvertJobsToDiggerJobs(jobs, projectMap, graph, 41584295, "", 2, "diggerhq", "parallel_jobs_demo", "diggerhq/parallel_jobs_demo", 123, "test", orchestrator_scheduler.BatchTypeApply)
735+
_, result, err := utils.ConvertJobsToDiggerJobs(1, jobs, projectMap, graph, 41584295, "", 2, "diggerhq", "parallel_jobs_demo", "diggerhq/parallel_jobs_demo", 123, "test", orchestrator_scheduler.BatchTypeApply)
736736
assert.NoError(t, err)
737737
assert.Equal(t, 1, len(result))
738738
parentLinks, err := models.DB.GetDiggerJobParentLinksChildId(&result["dev"].DiggerJobID)
@@ -761,7 +761,7 @@ func TestJobsTreeWithTwoDependantJobs(t *testing.T) {
761761
projectMap["dev"] = project1
762762
projectMap["prod"] = project2
763763

764-
_, result, err := utils.ConvertJobsToDiggerJobs(jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
764+
_, result, err := utils.ConvertJobsToDiggerJobs(1, jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
765765
assert.NoError(t, err)
766766
assert.Equal(t, 2, len(result))
767767

@@ -794,7 +794,7 @@ func TestJobsTreeWithTwoIndependentJobs(t *testing.T) {
794794
projectMap["dev"] = project1
795795
projectMap["prod"] = project2
796796

797-
_, result, err := utils.ConvertJobsToDiggerJobs(jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
797+
_, result, err := utils.ConvertJobsToDiggerJobs(1, jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
798798
assert.NoError(t, err)
799799
assert.Equal(t, 2, len(result))
800800
parentLinks, err := models.DB.GetDiggerJobParentLinksChildId(&result["dev"].DiggerJobID)
@@ -839,7 +839,7 @@ func TestJobsTreeWithThreeLevels(t *testing.T) {
839839
projectMap["555"] = project5
840840
projectMap["666"] = project6
841841

842-
_, result, err := utils.ConvertJobsToDiggerJobs(jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
842+
_, result, err := utils.ConvertJobsToDiggerJobs(1, jobs, projectMap, graph, 123, "", 2, "", "", "test", 123, "test", orchestrator_scheduler.BatchTypeApply)
843843
assert.NoError(t, err)
844844
assert.Equal(t, 6, len(result))
845845
parentLinks, err := models.DB.GetDiggerJobParentLinksChildId(&result["111"].DiggerJobID)

backend/migrations/20240409161739.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Create "job_tokens" table
2+
CREATE TABLE "public"."job_tokens" (
3+
"id" bigserial NOT NULL,
4+
"created_at" timestamptz NULL,
5+
"updated_at" timestamptz NULL,
6+
"deleted_at" timestamptz NULL,
7+
"value" text NULL,
8+
"expiry" timestamptz NULL,
9+
"organisation_id" bigint NULL,
10+
"type" text NULL,
11+
PRIMARY KEY ("id"),
12+
CONSTRAINT "fk_job_tokens_organisation" FOREIGN KEY ("organisation_id") REFERENCES "public"."organisations" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
13+
);
14+
-- Create index "idx_job_tokens_deleted_at" to table: "job_tokens"
15+
CREATE INDEX "idx_job_tokens_deleted_at" ON "public"."job_tokens" ("deleted_at");

backend/migrations/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:IoMAe7wNz/XdmLMzpgmtCvO0Pu1Kw0lZsufwdmjf0dE=
1+
h1:yIWTCl8ClNyBna56KDV5hF7yq68qD8QAv8SgM/GiA7E=
22
20231227132525.sql h1:43xn7XC0GoJsCnXIMczGXWis9d504FAWi4F1gViTIcw=
33
20240115170600.sql h1:IW8fF/8vc40+eWqP/xDK+R4K9jHJ9QBSGO6rN9LtfSA=
44
20240116123649.sql h1:R1JlUIgxxF6Cyob9HdtMqiKmx/BfnsctTl5rvOqssQw=
@@ -17,3 +17,4 @@ h1:IoMAe7wNz/XdmLMzpgmtCvO0Pu1Kw0lZsufwdmjf0dE=
1717
20240404165910.sql h1:ofwrBzkvnxFz7sOrtaF3vb2xHsenPmUTSSBHvO1NEdI=
1818
20240405150942.sql h1:0JIQlXqQmfgfBcill47gAef3LnnfdwK6ry98eHraUbo=
1919
20240405160110.sql h1:8bXZtrh8ZFFuCEXWIZ4fSjca0SSk1gsa2BqK7dIZ0To=
20+
20240409161739.sql h1:x0dZOsILJhmeQ6w8JKkllXZb2oz+QqV/PGLo+8R2pWI=

0 commit comments

Comments
 (0)