fix: fixed function to work properly
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
2d4102be6a
commit
768203ebd7
@ -69,7 +69,7 @@ func GetAllTagByTagsType(ctx context.Context, db *gorm.DB, tagType models.TagTyp
|
||||
return nil, &otterError.EntityValidationFailed{Reason: "tagType cannot be empty"}
|
||||
}
|
||||
|
||||
result := db.WithContext(ctx).Find(&tags).Where("tag_type = ?", tagType)
|
||||
result := db.WithContext(ctx).Model(&models.Tag{}).Where("tag_type = ?", tagType).Scan(&tags)
|
||||
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
|
@ -1050,6 +1050,21 @@ func TestGetAllTagByTagType(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
expectetResult := []models.Tag{
|
||||
{
|
||||
Name: "JayTheFerret",
|
||||
Type: models.Character,
|
||||
},
|
||||
{
|
||||
Name: "SoXX",
|
||||
Type: models.Character,
|
||||
},
|
||||
{
|
||||
Name: "Alphyron",
|
||||
Type: models.Character,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tag := range validTags {
|
||||
err = CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
||||
if err != nil {
|
||||
@ -1076,7 +1091,7 @@ func TestGetAllTagByTagType(t *testing.T) {
|
||||
db: gormDB,
|
||||
tagType: models.Character,
|
||||
},
|
||||
want: validTags,
|
||||
want: expectetResult,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
@ -3174,6 +3174,21 @@ func Test_postgresqlConnection_GetAllTagsByTagType(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
expectetResult := []models.Tag{
|
||||
{
|
||||
Name: "JayTheFerret",
|
||||
Type: models.Character,
|
||||
},
|
||||
{
|
||||
Name: "SoXX",
|
||||
Type: models.Character,
|
||||
},
|
||||
{
|
||||
Name: "Alphyron",
|
||||
Type: models.Character,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tag := range validTags {
|
||||
err = postgres.CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
||||
if err != nil {
|
||||
@ -3198,7 +3213,7 @@ func Test_postgresqlConnection_GetAllTagsByTagType(t *testing.T) {
|
||||
ctx: ctx,
|
||||
tagType: models.Character,
|
||||
},
|
||||
want: validTags,
|
||||
want: expectetResult,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user