github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/query/common/aql_query_result_test.go (about)

     1  //  Copyright (c) 2017-2018 Uber Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package common
    16  
    17  import (
    18  	"github.com/onsi/ginkgo"
    19  	. "github.com/onsi/gomega"
    20  )
    21  
    22  var _ = ginkgo.Describe("time series result", func() {
    23  	ginkgo.It("SetHLL should work", func() {
    24  		res := AQLQueryResult{}
    25  		dim0 := "dim0"
    26  		dim1 := "dim1"
    27  		res.SetHLL([]*string{&dim0, &dim1, nil}, HLL{NonZeroRegisters: 1})
    28  		Ω(res).Should(Equal(AQLQueryResult{
    29  			"dim0": map[string]interface{}{
    30  				"dim1": map[string]interface{}{
    31  					"NULL": HLL{DenseData: nil, NonZeroRegisters: 1},
    32  				},
    33  			},
    34  		}))
    35  	})
    36  
    37  	ginkgo.It("Set should work", func() {
    38  		res := AQLQueryResult{}
    39  		dim0 := "dim0"
    40  		dim1 := "dim1"
    41  		v := 0.01
    42  		res.Set([]*string{&dim0, &dim1, nil}, &v)
    43  		Ω(res).Should(Equal(AQLQueryResult{
    44  			"dim0": map[string]interface{}{
    45  				"dim1": map[string]interface{}{
    46  					"NULL": 0.01,
    47  				},
    48  			},
    49  		}))
    50  	})
    51  
    52  	ginkgo.It("Append should work", func() {
    53  		res := AQLQueryResult{}
    54  		str := "1"
    55  		res.Append([]*string{&str})
    56  		Ω(res).Should(Equal(AQLQueryResult{
    57  			"matrixData": [][]interface{}{
    58  				{"1"},
    59  			},
    60  		}))
    61  	})
    62  
    63  	ginkgo.It("SetHeaders should work", func() {
    64  		res := AQLQueryResult{}
    65  		res.SetHeaders([]string{"field1", "field2"})
    66  		Ω(res).Should(Equal(AQLQueryResult{
    67  			"headers": []string{"field1", "field2"},
    68  		}))
    69  	})
    70  })