0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-05 21:16:11 +01:00
gitea/modules/setting/config/value_test.go
Mark Brown 589712db26
feat: inverted disable_gravatar logic to enable_gravatar
Frontend still interacts directly with the database entry name
`picture.disable_gravatar` so logic needs flipped when writing, but
logic to read automatically flips based on config.Invert() being called
during init or INI read.
2025-10-16 21:01:44 -04:00

36 lines
789 B
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package config
import (
"testing"
)
func TestValue_parse(t *testing.T) {
tests := []struct {
name string // description of this test case
// Named input parameters for target function.
key string
valStr string
want bool
}{
{
name: "Parse Invert Retrieval",
key: "picture.disable_gravatar",
valStr: "false",
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
value := ValueJSON[bool]("picture.disable_gravatar").WithFileConfig(CfgSecKey{Sec: "picture", Key: "DISABLE_GRAVATAR"}).Invert()
got := value.parse(tt.key, tt.valStr)
if got != tt.want {
t.Errorf("parse() = %v, want %v", got, tt.want)
}
})
}
}