github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/api/request_test.go (about) 1 package api 2 3 import ( 4 "bytes" 5 "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 "net/http" 8 ) 9 10 var _ = ginkgo.Describe("api request", func() { 11 12 ginkgo.It("ReadRequest should work", func() { 13 query := ` 14 { 15 "queries":[ 16 { 17 "measures": [ 18 { 19 "sqlExpression": "hll(driver_uuid_hll)" 20 } 21 ], 22 "rowFilters": [ 23 "trips.status = 'completed'" 24 ], 25 "table": "trips", 26 "timeFilter": { 27 "column": "trips.request_at", 28 "from": "2018-09-18", 29 "to": "2018-09-24" 30 }, 31 "dimensions": [ 32 { 33 "sqlExpression": "request_at", 34 "timeBucketizer": "day", 35 "timeUnit": "second" 36 } 37 ] 38 } 39 ] 40 } 41 ` 42 bts := []byte(query) 43 r, err := http.NewRequest(http.MethodPost, "localhost:19374", bytes.NewBuffer(bts)) 44 Ω(err).Should(BeNil()) 45 r.Header.Set("Accept", "application/hll") 46 aqlR := AQLRequest{} 47 err = ReadRequest(r, &aqlR) 48 Ω(err).Should(BeNil()) 49 Ω(aqlR.Accept).Should(Equal(ContentTypeHyperLogLog)) 50 }) 51 52 })