github.com/thanos-io/thanos@v0.32.5/pkg/store/hintspb/custom_test.go (about)

     1  // Copyright (c) The Thanos Authors.
     2  // Licensed under the Apache License 2.0.
     3  
     4  package hintspb
     5  
     6  import (
     7  	"reflect"
     8  	"testing"
     9  
    10  	"github.com/efficientgo/core/testutil"
    11  )
    12  
    13  func TestQueryStatsMerge(t *testing.T) {
    14  	s := &QueryStats{}
    15  	ps := reflect.Indirect(reflect.ValueOf(s))
    16  	for i := 0; i < ps.NumField(); i++ {
    17  		ps.FieldByIndex([]int{i}).SetInt(int64(1))
    18  	}
    19  	o := &QueryStats{}
    20  	po := reflect.Indirect(reflect.ValueOf(o))
    21  	for i := 0; i < po.NumField(); i++ {
    22  		po.FieldByIndex([]int{i}).SetInt(int64(100))
    23  	}
    24  	s.Merge(o)
    25  
    26  	// Expected stats.
    27  	e := &QueryStats{}
    28  	pe := reflect.Indirect(reflect.ValueOf(e))
    29  	for i := 0; i < pe.NumField(); i++ {
    30  		pe.FieldByIndex([]int{i}).SetInt(int64(101))
    31  	}
    32  	testutil.Equals(t, e, s)
    33  }