mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-27 10:53:44 +02:00
src/api/log_params.go: Adding Combine()
This commit is contained in:
parent
8d2c1c8fa3
commit
8079962be8
2 changed files with 22 additions and 0 deletions
|
|
@ -6,3 +6,9 @@ type LogParams []interface{}
|
|||
func (p *LogParams) Add(field string, value interface{}) {
|
||||
*p = append(*p, field, value)
|
||||
}
|
||||
|
||||
// Syntactic sugar for append(p, other...)
|
||||
// Returns a new instance of LogParams with all values from both p and other
|
||||
func (p LogParams) Combine(other LogParams) LogParams {
|
||||
return append(p, other...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,3 +32,19 @@ func TestLogParams(t *testing.T) {
|
|||
|
||||
assert.ElementsMatch(t, expected, p)
|
||||
}
|
||||
|
||||
func TestLogParamsCombine(t *testing.T) {
|
||||
|
||||
a := LogParams{"one",1,"string1","str1"}
|
||||
|
||||
b := LogParams{"two",2,"string2","str2"}
|
||||
|
||||
expected := LogParams{
|
||||
"one",1,
|
||||
"string1","str1",
|
||||
"two",2,
|
||||
"string2","str2",
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, a.Combine(b))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue