mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Add support for removing custom field keys (#6362)
This commit is contained in:
@@ -64,6 +64,18 @@ func TestSetCustomFields(t *testing.T) {
|
||||
}),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"valid remove",
|
||||
models.CustomFieldsInput{
|
||||
Remove: []string{"real"},
|
||||
},
|
||||
func() map[string]interface{} {
|
||||
m := getPerformerCustomFields(performerIdx)
|
||||
delete(m, "real")
|
||||
return m
|
||||
}(),
|
||||
false,
|
||||
},
|
||||
{
|
||||
"leading space full",
|
||||
models.CustomFieldsInput{
|
||||
@@ -144,16 +156,38 @@ func TestSetCustomFields(t *testing.T) {
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid remove full",
|
||||
models.CustomFieldsInput{
|
||||
Full: map[string]interface{}{
|
||||
"key": "value",
|
||||
},
|
||||
Remove: []string{"key"},
|
||||
},
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid remove partial",
|
||||
models.CustomFieldsInput{
|
||||
Partial: map[string]interface{}{
|
||||
"real": float64(4.56),
|
||||
},
|
||||
Remove: []string{"real"},
|
||||
},
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
// use performer custom fields store
|
||||
store := db.Performer
|
||||
id := performerIDs[performerIdx]
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
for _, tt := range tests {
|
||||
runWithRollbackTxn(t, tt.name, func(t *testing.T, ctx context.Context) {
|
||||
assert := assert.New(t)
|
||||
|
||||
err := store.SetCustomFields(ctx, id, tt.input)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("SetCustomFields() error = %v, wantErr %v", err, tt.wantErr)
|
||||
|
||||
Reference in New Issue
Block a user