Skip to content

Commit 80c8b1a

Browse files
authored
Merge branch 'master' into missing_docs_findings
2 parents 4d4482d + 6e66ffa commit 80c8b1a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/collector/capacity_scrape_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ package collector_test
55

66
import (
77
"encoding/json"
8-
"errors"
98
"fmt"
109
"net/http"
10+
"regexp"
1111
"strings"
1212
"testing"
1313
"time"
@@ -21,7 +21,6 @@ import (
2121
"github.com/sapcc/go-bits/easypg"
2222
"github.com/sapcc/go-bits/jobloop"
2323
"github.com/sapcc/go-bits/must"
24-
"github.com/sapcc/go-bits/sqlext"
2524

2625
"github.com/sapcc/limes/internal/collector"
2726
"github.com/sapcc/limes/internal/datamodel"
@@ -1137,10 +1136,12 @@ func Test_ScanCapacityWithCommitments(t *testing.T) {
11371136
})
11381137

11391138
s.Clock.StepBy(1 * time.Hour)
1140-
mustFailT(t, jobloop.ProcessMany(job, s.Ctx, len(s.Cluster.LiquidConnections)), errors.New(sqlext.SimplifyWhitespace(
1141-
`failed in iteration 2: while scraping service 2: could not delete db.Resource record with key capacity:
1142-
pq: update or delete on table "az_resources" violates foreign key constraint "project_commitments_az_resource_id_fkey" on table "project_commitments"
1143-
(additional error while updating DB: pq: update or delete on table "services" violates foreign key constraint "resources_service_id_liquid_version_fkey" on table "resources"`)))
1139+
err := jobloop.ProcessMany(job, s.Ctx, len(s.Cluster.LiquidConnections))
1140+
assert.ErrEqual(t, err, regexp.MustCompile(
1141+
// the error is that ON DELETE CASCADE on services -> resources is stopped by ON DELETE RESTRICT on resources -> commitments;
1142+
// we do not match the specific phrasing of the PostgreSQL error since it may change between versions
1143+
`^failed in iteration 2: while scraping service 2: could not delete db.Resource record with key capacity:.*"project_commitments_az_resource_id_fkey"`,
1144+
))
11441145
}
11451146

11461147
func TestScanCapacityWithMailNotification(t *testing.T) {

0 commit comments

Comments
 (0)