Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ba3463

Browse files
committed
Remove use of panics
1 parent7fc8ead commit5ba3463

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎coderd/database/databasefake/generator.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ type Generator struct {
3131

3232
funcNewGenerator(t*testing.T,db database.Store)*Generator {
3333
if_,ok:=db.(FakeDatabase);!ok {
34-
panic("Generator db must be a FakeDatabase")
34+
// This does not work for postgres databases because of foreign key
35+
// constraints
36+
t.Fatalf("Generator db must be a FakeDatabase")
3537
}
3638
return&Generator{
3739
names:make(map[string]uuid.UUID),
@@ -58,6 +60,7 @@ func (g *Generator) PrimaryOrg(ctx context.Context) database.Organization {
5860
}
5961

6062
funcpopulate[DBTypeany](ctx context.Context,g*Generator,namestring,seedDBType)DBType {
63+
g.testT.Helper()
6164
ifname=="" {
6265
name=g.RandomName()
6366
}
@@ -67,7 +70,7 @@ func populate[DBType any](ctx context.Context, g *Generator, name string, seed D
6770
})
6871
v,ok:=out[name].(DBType)
6972
if!ok {
70-
panic("developer error, type mismatch")
73+
g.testT.Fatalf("developer error, type mismatch in data generator")
7174
}
7275
returnv
7376
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp