diff --git a/database/pipeline/pipeline_test.go b/database/pipeline/pipeline_test.go index f478fe37f..13d01393a 100644 --- a/database/pipeline/pipeline_test.go +++ b/database/pipeline/pipeline_test.go @@ -5,6 +5,7 @@ package pipeline import ( + "context" "database/sql/driver" "reflect" "testing" @@ -65,6 +66,7 @@ func TestPipeline_New(t *testing.T) { want: &engine{ client: _postgres, config: &config{CompressionLevel: 1, SkipCreation: false}, + ctx: context.TODO(), logger: logger, }, }, @@ -78,6 +80,7 @@ func TestPipeline_New(t *testing.T) { want: &engine{ client: _sqlite, config: &config{CompressionLevel: 1, SkipCreation: false}, + ctx: context.TODO(), logger: logger, }, }, @@ -87,6 +90,7 @@ func TestPipeline_New(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { got, err := New( + WithContext(context.TODO()), WithClient(test.client), WithCompressionLevel(test.level), WithLogger(test.logger), diff --git a/database/resource_test.go b/database/resource_test.go index 36a4694e6..233dbb800 100644 --- a/database/resource_test.go +++ b/database/resource_test.go @@ -5,6 +5,7 @@ package database import ( + "context" "testing" "github.com/DATA-DOG/go-sqlmock" @@ -94,7 +95,7 @@ func TestDatabase_Engine_NewResources(t *testing.T) { // run tests for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := test.database.NewResources() + err := test.database.NewResources(context.TODO()) if test.failure { if err == nil { diff --git a/router/middleware/pipeline/pipeline.go b/router/middleware/pipeline/pipeline.go index 1910e2c0f..b3f2e57af 100644 --- a/router/middleware/pipeline/pipeline.go +++ b/router/middleware/pipeline/pipeline.go @@ -32,6 +32,7 @@ func Establish() gin.HandlerFunc { o := org.Retrieve(c) r := repo.Retrieve(c) u := user.Retrieve(c) + ctx := c.Request.Context() if r == nil { retErr := fmt.Errorf("repo %s/%s not found", util.PathParameter(c, "org"), util.PathParameter(c, "repo")) @@ -62,7 +63,7 @@ func Establish() gin.HandlerFunc { "user": u.GetName(), }).Debugf("reading pipeline %s", entry) - pipeline, err := database.FromContext(c).GetPipelineForRepo(p, r) + pipeline, err := database.FromContext(c).GetPipelineForRepo(ctx, p, r) if err != nil { // assume the pipeline doesn't exist in the database yet (before pipeline support was added) // send API call to capture the pipeline configuration file config, err := scm.FromContext(c).ConfigBackoff(u, r, p) diff --git a/router/middleware/pipeline/pipeline_test.go b/router/middleware/pipeline/pipeline_test.go index 4e7912372..b29f1aee2 100644 --- a/router/middleware/pipeline/pipeline_test.go +++ b/router/middleware/pipeline/pipeline_test.go @@ -5,6 +5,7 @@ package pipeline import ( + "context" "flag" "fmt" "net/http" @@ -102,13 +103,13 @@ func TestPipeline_Establish(t *testing.T) { } defer func() { - db.DeletePipeline(want) + db.DeletePipeline(context.TODO(), want) db.DeleteRepo(r) db.Close() }() _, _ = db.CreateRepo(r) - _, _ = db.CreatePipeline(want) + _, _ = db.CreatePipeline(context.TODO(), want) // setup context gin.SetMode(gin.TestMode)