Skip to content

Commit c533f58

Browse files
泽华Rader
authored andcommitted
Fix create tag bug
1 parent 8350f6a commit c533f58

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

builder/store/database/tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (ts *tagStoreImpl) AllCategories(ctx context.Context, scope types.TagScope)
192192
}
193193

194194
func (ts *tagStoreImpl) CreateTag(ctx context.Context, tag Tag) (*Tag, error) {
195-
_, err := ts.db.Operator.Core.NewInsert().Model(&tag).Exec(ctx)
195+
err := ts.db.Operator.Core.NewInsert().Model(&tag).Scan(ctx, &tag)
196196
return &tag, err
197197
}
198198

builder/store/database/tag_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestTagStore_AllTags(t *testing.T) {
7777

7878
tag = database.Tag{
7979
Category: "task",
80-
Name: "tag_" + uuid.New().String(),
80+
Name: "tag_" + uuid.New().String() + "search",
8181
Group: "Group One",
8282
Scope: types.CodeTagScope,
8383
}
@@ -86,7 +86,7 @@ func TestTagStore_AllTags(t *testing.T) {
8686

8787
tag = database.Tag{
8888
Category: "library",
89-
Name: "tag_" + uuid.New().String(),
89+
Name: "tag_" + uuid.New().String() + "search",
9090
Group: "Group One",
9191
Scope: types.PromptTagScope,
9292
}
@@ -370,7 +370,7 @@ func TestTagStore_CreateTag(t *testing.T) {
370370
ts := database.NewTagStoreWithDB(db)
371371
tag := database.Tag{
372372
Category: "task",
373-
Name: "tag_" + uuid.New().String(),
373+
Name: "tag_" + uuid.NewString(),
374374
Group: "",
375375
Scope: types.ModelTagScope,
376376
}
@@ -489,7 +489,7 @@ func TestTagStore_SetLibraryTag(t *testing.T) {
489489
ts := database.NewTagStoreWithDB(db)
490490
tag := database.Tag{
491491
Category: "task",
492-
Name: "tag_" + uuid.New().String(),
492+
Name: "tag_" + uuid.NewString(),
493493
Group: "",
494494
Scope: types.ModelTagScope,
495495
}
@@ -498,7 +498,7 @@ func TestTagStore_SetLibraryTag(t *testing.T) {
498498

499499
tag = database.Tag{
500500
Category: "task",
501-
Name: "tag_" + uuid.New().String(),
501+
Name: "tag_" + uuid.NewString(),
502502
Group: "",
503503
Scope: types.ModelTagScope,
504504
}
@@ -525,7 +525,7 @@ func TestTagStore_UpsertRepoTags(t *testing.T) {
525525
ts := database.NewTagStoreWithDB(db)
526526
tag := database.Tag{
527527
Category: "task",
528-
Name: "tag_" + uuid.New().String(),
528+
Name: "tag_" + uuid.NewString(),
529529
Group: "",
530530
Scope: types.ModelTagScope,
531531
}
@@ -556,7 +556,7 @@ func TestTagStore_UpsertRepoTags(t *testing.T) {
556556

557557
tag = database.Tag{
558558
Category: "task",
559-
Name: "tag_" + uuid.New().String(),
559+
Name: "tag_" + uuid.NewString(),
560560
Group: "",
561561
Scope: types.ModelTagScope,
562562
}
@@ -584,17 +584,16 @@ func TestTagStore_RemoveRepoTags(t *testing.T) {
584584
ts := database.NewTagStoreWithDB(db)
585585
tag := database.Tag{
586586
Category: "task",
587-
Name: "tag_" + uuid.New().String(),
587+
Name: "tag_" + uuid.NewString(),
588588
Group: "",
589589
Scope: types.ModelTagScope,
590590
}
591591
tag1, err := ts.CreateTag(ctx, tag)
592592
require.Empty(t, err)
593593
require.NotEmpty(t, tag1.ID)
594-
595594
tag = database.Tag{
596595
Category: "task",
597-
Name: "tag_" + uuid.New().String(),
596+
Name: "tag_" + uuid.NewString(),
598597
Group: "",
599598
Scope: types.ModelTagScope,
600599
}
@@ -645,7 +644,7 @@ func TestTagStore_RemoveRepoTagsByCategory(t *testing.T) {
645644
ts := database.NewTagStoreWithDB(db)
646645
tag := database.Tag{
647646
Category: "task",
648-
Name: "tag_" + uuid.New().String(),
647+
Name: "tag_" + uuid.NewString(),
649648
Group: "",
650649
Scope: types.ModelTagScope,
651650
}
@@ -654,7 +653,7 @@ func TestTagStore_RemoveRepoTagsByCategory(t *testing.T) {
654653
require.NotEmpty(t, tag1.ID)
655654
tag = database.Tag{
656655
Category: "task",
657-
Name: "tag_" + uuid.New().String(),
656+
Name: "tag_" + uuid.NewString(),
658657
Group: "",
659658
Scope: types.ModelTagScope,
660659
}
@@ -698,7 +697,7 @@ func TestTagStore_FindTagByID(t *testing.T) {
698697
ts := database.NewTagStoreWithDB(db)
699698
tag := database.Tag{
700699
Category: "task",
701-
Name: "tag_" + uuid.New().String(),
700+
Name: "tag_" + uuid.NewString(),
702701
Group: "",
703702
Scope: types.ModelTagScope,
704703
}
@@ -723,7 +722,7 @@ func TestTagStore_UpdateTagByID(t *testing.T) {
723722

724723
tag := database.Tag{
725724
Category: "task",
726-
Name: "tag_" + uuid.New().String(),
725+
Name: "tag_" + uuid.NewString(),
727726
Group: "",
728727
Scope: types.ModelTagScope,
729728
}
@@ -751,7 +750,7 @@ func TestTagStore_DeleteTagByID(t *testing.T) {
751750
ts := database.NewTagStoreWithDB(db)
752751
tag := database.Tag{
753752
Category: "task",
754-
Name: "tag_" + uuid.New().String(),
753+
Name: "tag_" + uuid.NewString(),
755754
Group: "",
756755
Scope: types.ModelTagScope,
757756
}

0 commit comments

Comments
 (0)