Skip to content

Commit

Permalink
fix db tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Feb 2, 2024
1 parent ec0a038 commit 8dc2c94
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions database/build/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestBuild_Engine_CleanBuilds(t *testing.T) {
defer func() { _sql, _ := _postgres.client.DB(); _sql.Close() }()

// ensure the mock expects the name query
_mock.ExpectExec(`UPDATE "builds" SET "status"=$1,"error"=$2,"finished"=$3,"deploy_number"=$4,"deploy_payload"=$5 WHERE created < $6 AND (status = 'running' OR status = 'pending')`).
WithArgs("error", "msg", NowTimestamp{}, 0, AnyArgument{}, 3).
_mock.ExpectExec(`UPDATE "builds" SET "status"=$1,"error"=$2,"finished"=$3,"deploy_payload"=$4 WHERE created < $5 AND (status = 'running' OR status = 'pending')`).
WithArgs("error", "msg", NowTimestamp{}, AnyArgument{}, 3).
WillReturnResult(sqlmock.NewResult(1, 2))

_sqlite := testSqlite(t)
Expand Down
3 changes: 1 addition & 2 deletions database/build/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestBuild_Engine_CreateBuild(t *testing.T) {
_build.SetID(1)
_build.SetRepoID(1)
_build.SetNumber(1)
_build.SetDeployNumber(0)
_build.SetDeployPayload(nil)

_postgres, _mock := testPostgres(t)
Expand All @@ -29,7 +28,7 @@ func TestBuild_Engine_CreateBuild(t *testing.T) {
_mock.ExpectQuery(`INSERT INTO "builds"
("repo_id","pipeline_id","number","parent","event","event_action","status","error","enqueued","created","started","finished","deploy","deploy_number","deploy_payload","clone","source","title","message","commit","sender","author","email","link","branch","ref","base_ref","head_ref","host","runtime","distribution","approved_at","approved_by","id")
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34) RETURNING "id"`).
WithArgs(1, nil, 1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0, AnyArgument{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 1).
WithArgs(1, nil, 1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, AnyArgument{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 1).
WillReturnRows(_rows)

_sqlite := testSqlite(t)
Expand Down
3 changes: 1 addition & 2 deletions database/build/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestBuild_Engine_UpdateBuild(t *testing.T) {
_build.SetID(1)
_build.SetRepoID(1)
_build.SetNumber(1)
_build.SetDeployNumber(0)
_build.SetDeployPayload(nil)

_postgres, _mock := testPostgres(t)
Expand All @@ -26,7 +25,7 @@ func TestBuild_Engine_UpdateBuild(t *testing.T) {
_mock.ExpectExec(`UPDATE "builds"
SET "repo_id"=$1,"pipeline_id"=$2,"number"=$3,"parent"=$4,"event"=$5,"event_action"=$6,"status"=$7,"error"=$8,"enqueued"=$9,"created"=$10,"started"=$11,"finished"=$12,"deploy"=$13,"deploy_number"=$14,"deploy_payload"=$15,"clone"=$16,"source"=$17,"title"=$18,"message"=$19,"commit"=$20,"sender"=$21,"author"=$22,"email"=$23,"link"=$24,"branch"=$25,"ref"=$26,"base_ref"=$27,"head_ref"=$28,"host"=$29,"runtime"=$30,"distribution"=$31,"approved_at"=$32,"approved_by"=$33
WHERE "id" = $34`).
WithArgs(1, nil, 1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0, AnyArgument{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 1).
WithArgs(1, nil, 1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, AnyArgument{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 1).
WillReturnResult(sqlmock.NewResult(1, 1))

_sqlite := testSqlite(t)
Expand Down

0 comments on commit 8dc2c94

Please sign in to comment.