mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
Fix: tojson(null) == 'null' (#1068)
* Fix: tojson(null) == 'null' * Update test * Update functions_test.go
This commit is contained in:
parent
f93a6e2817
commit
d890923f0e
2 changed files with 2 additions and 1 deletions
|
@ -151,7 +151,7 @@ func (impl *interperterImpl) join(array reflect.Value, sep reflect.Value) (strin
|
||||||
|
|
||||||
func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) {
|
func (impl *interperterImpl) toJSON(value reflect.Value) (string, error) {
|
||||||
if value.Kind() == reflect.Invalid {
|
if value.Kind() == reflect.Invalid {
|
||||||
return "", nil
|
return "null", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
json, err := json.MarshalIndent(value.Interface(), "", " ")
|
json, err := json.MarshalIndent(value.Interface(), "", " ")
|
||||||
|
|
|
@ -137,6 +137,7 @@ func TestFunctionToJSON(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
}{
|
}{
|
||||||
{"toJSON(env) }}", "{\n \"key\": \"value\"\n}", "toJSON"},
|
{"toJSON(env) }}", "{\n \"key\": \"value\"\n}", "toJSON"},
|
||||||
|
{"toJSON(null)", "null", "toJSON-null"},
|
||||||
}
|
}
|
||||||
|
|
||||||
env := &EvaluationEnvironment{
|
env := &EvaluationEnvironment{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue