You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: db_test.go
    path of file: ./repos/cockroach/pkg/ts/testmodel
    
    the code of the file until where you have to start completion: // Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package testmodel

import (
	"math"
	"reflect"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/ts/tspb"
)

// TestModelDBQuery is a high-level verification that the test model query
// system is assembled correctly. The query system is implemented primarily
// through the various immutable functions on the DataSeries type, which are
// tested extensively individually; therefore, this test seeks primarily to
// establish that those well-tested components are assembled correctly.
func TestModelDBQuery(t *testing.T) {
	db := NewModelDB()
	db.Record("testmetric", "source1", DataSeries{
		dp(0, 0.0),
		dp(100, 100.0),
		dp(200, 200.0),
		dp(400, 400.0),
	})
	db.Record("testmetric", "source2", DataSeries{
		dp(0, 0.0),
		dp(103, 50.0),
		dp(199, 150.0),
		dp(205, 400.0),
		dp(3
    
func TestModelDBAggregators(t *testing.T) {
	db := NewModelDB()
	data := DataSeries{
		dp(0, 0.0),
		dp(50, 100.0),
		dp(100, 200.0),
		dp(150, 600.0),
	}
	data2 := DataSeries{
		dp(0, 100.0),
		dp(50, 200.0),
		dp(100, 400.0),
		dp(150, 800.0),
	}
	db.Record("testmetric", "source1", data)
	db.Record("testmetric", "source2", data2)
	for _, test := range []struct {
		fn         aggFunc
		aggregator tspb.TimeSeriesQueryAggregator
	}{
		{
			fn:         AggregateAverage,
			aggregator: tspb.TimeSeriesQueryAggregator_AVG,
		},
		{
			fn:         AggregateSum,
			aggregator: tspb.TimeSeriesQueryAggregator_SUM,
		},
		{
			fn:         AggregateMin,
			aggregator: tspb.TimeSeriesQueryAggregator_MIN,
		},
		{
			fn:         AggregateMax,
			aggregator: tspb.TimeSeriesQueryAggregator_MAX,
		},
		{
			fn:         AggregateVariance,
			aggregator: tspb.TimeSeriesQueryAggregator_VARIANCE,
		},
		// First and Last are not valid for source aggregation, as sources are not
		// ordered.
	} {
		t.Run(test.aggregator.String(), func(t *testing.T) {
			expected := groupSeriesByTimestamp([]DataSeries{data, data2}, test.fn)
			actual := db.Query(
				"testmetric",
				nil,
				tspb.TimeSeriesQueryAggregator_LAST,
				test.aggregator,
				tspb.TimeSeriesQueryDerivative_NONE,
				1000,          /* slabduration */
				1,             /* sampleDuration */
				0,             /* start */
				200,           /* end */
				10000,         /* interpolationLimitNanos */
				math.MaxInt64, /* nowNanos */
			)
			if !reflect.DeepEqual(actual, expected) {
				t.Errorf("Query() got %v, wanted %v", actual, expected)
			}
		})
	}
}