1
0
mirror of https://codeberg.org/crowci/crow.git synced 2025-08-07 20:23:03 +03:00

Replace interface{} with any (#2807)

like golang:
2580d0e08d
This commit is contained in:
qwerty287
2023-11-12 18:23:48 +01:00
committed by GitHub
parent fd77b2e9d7
commit 70711ed9db
35 changed files with 106 additions and 106 deletions

View File

@@ -22,21 +22,21 @@ import (
)
func TestParamsToEnv(t *testing.T) {
from := map[string]interface{}{
from := map[string]any{
"skip": nil,
"string": "stringz",
"int": 1,
"float": 1.2,
"bool": true,
"slice": []int{1, 2, 3},
"map": map[string]interface{}{"hello": "world"},
"map": map[string]any{"hello": "world"},
"complex": []struct{ Name string }{{"Jack"}, {"Jill"}},
"complex2": struct{ Name string }{"Jack"},
"from.address": "noreply@example.com",
"tags": stringsToInterface("next", "latest"),
"tag": stringsToInterface("next"),
"my_secret": map[string]interface{}{"from_secret": "secret_token"},
"UPPERCASE_SECRET": map[string]interface{}{"from_secret": "SECRET_TOKEN"},
"my_secret": map[string]any{"from_secret": "secret_token"},
"UPPERCASE_SECRET": map[string]any{"from_secret": "SECRET_TOKEN"},
}
want := map[string]string{
"PLUGIN_STRING": "stringz",
@@ -62,7 +62,7 @@ func TestParamsToEnv(t *testing.T) {
// handle edge cases (#1609)
got = map[string]string{}
assert.NoError(t, ParamsToEnv(map[string]interface{}{"a": []interface{}{"a", nil}}, got, nil))
assert.NoError(t, ParamsToEnv(map[string]any{"a": []any{"a", nil}}, got, nil))
assert.EqualValues(t, map[string]string{"PLUGIN_A": "a,"}, got)
}
@@ -95,7 +95,7 @@ list.map:
password:
from_secret: cb_password
`)
var from map[string]interface{}
var from map[string]any
err := yaml.Unmarshal(fromYAML, &from)
assert.NoError(t, err)
@@ -122,7 +122,7 @@ func TestYAMLToParamsToEnvError(t *testing.T) {
fromYAML := []byte(`my_secret:
from_secret: not_a_secret
`)
var from map[string]interface{}
var from map[string]any
err := yaml.Unmarshal(fromYAML, &from)
assert.NoError(t, err)
secrets := map[string]string{
@@ -131,8 +131,8 @@ func TestYAMLToParamsToEnvError(t *testing.T) {
assert.Error(t, ParamsToEnv(from, make(map[string]string), secrets))
}
func stringsToInterface(val ...string) []interface{} {
res := make([]interface{}, len(val))
func stringsToInterface(val ...string) []any {
res := make([]any, len(val))
for i := range val {
res[i] = val[i]
}