-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix series stats merge Signed-off-by: Ben Ye <[email protected]> * update license header Signed-off-by: Ben Ye <[email protected]> * use reflect Signed-off-by: Ben Ye <[email protected]> --------- Signed-off-by: Ben Ye <[email protected]>
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package hintspb | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/efficientgo/core/testutil" | ||
) | ||
|
||
func TestQueryStatsMerge(t *testing.T) { | ||
s := &QueryStats{} | ||
ps := reflect.Indirect(reflect.ValueOf(s)) | ||
for i := 0; i < ps.NumField(); i++ { | ||
ps.FieldByIndex([]int{i}).SetInt(int64(1)) | ||
} | ||
o := &QueryStats{} | ||
po := reflect.Indirect(reflect.ValueOf(o)) | ||
for i := 0; i < po.NumField(); i++ { | ||
po.FieldByIndex([]int{i}).SetInt(int64(100)) | ||
} | ||
s.Merge(o) | ||
|
||
// Expected stats. | ||
e := &QueryStats{} | ||
pe := reflect.Indirect(reflect.ValueOf(e)) | ||
for i := 0; i < pe.NumField(); i++ { | ||
pe.FieldByIndex([]int{i}).SetInt(int64(101)) | ||
} | ||
testutil.Equals(t, e, s) | ||
} |