| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package bigtable | 5 package bigtable |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "strconv" | 9 "strconv" |
| 10 "testing" | 10 "testing" |
| 11 | 11 |
| 12 "github.com/luci/luci-go/common/config" | |
| 13 "github.com/luci/luci-go/common/data/recordio" | 12 "github.com/luci/luci-go/common/data/recordio" |
| 14 "github.com/luci/luci-go/logdog/common/storage" | 13 "github.com/luci/luci-go/logdog/common/storage" |
| 15 "github.com/luci/luci-go/logdog/common/storage/memory" | 14 "github.com/luci/luci-go/logdog/common/storage/memory" |
| 16 "github.com/luci/luci-go/logdog/common/types" | 15 "github.com/luci/luci-go/logdog/common/types" |
| 16 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 17 "golang.org/x/net/context" | 17 "golang.org/x/net/context" |
| 18 | 18 |
| 19 . "github.com/luci/luci-go/common/testing/assertions" | 19 . "github.com/luci/luci-go/common/testing/assertions" |
| 20 . "github.com/smartystreets/goconvey/convey" | 20 . "github.com/smartystreets/goconvey/convey" |
| 21 ) | 21 ) |
| 22 | 22 |
| 23 func mustGetIndex(e *storage.Entry) types.MessageIndex { | 23 func mustGetIndex(e *storage.Entry) types.MessageIndex { |
| 24 idx, err := e.GetStreamIndex() | 24 idx, err := e.GetStreamIndex() |
| 25 if err != nil { | 25 if err != nil { |
| 26 panic(err) | 26 panic(err) |
| 27 } | 27 } |
| 28 return idx | 28 return idx |
| 29 } | 29 } |
| 30 | 30 |
| 31 func TestStorage(t *testing.T) { | 31 func TestStorage(t *testing.T) { |
| 32 t.Parallel() | 32 t.Parallel() |
| 33 | 33 |
| 34 Convey(`A BigTable storage instance bound to a testing BigTable instance
`, t, func() { | 34 Convey(`A BigTable storage instance bound to a testing BigTable instance
`, t, func() { |
| 35 var cache memory.Cache | 35 var cache memory.Cache |
| 36 s := NewMemoryInstance(context.Background(), Options{ | 36 s := NewMemoryInstance(context.Background(), Options{ |
| 37 Cache: &cache, | 37 Cache: &cache, |
| 38 }) | 38 }) |
| 39 defer s.Close() | 39 defer s.Close() |
| 40 | 40 |
| 41 » » project := config.ProjectName("test-project") | 41 » » project := cfgtypes.ProjectName("test-project") |
| 42 get := func(path string, index int, limit int, keysOnly bool) ([
]string, error) { | 42 get := func(path string, index int, limit int, keysOnly bool) ([
]string, error) { |
| 43 req := storage.GetRequest{ | 43 req := storage.GetRequest{ |
| 44 Project: project, | 44 Project: project, |
| 45 Path: types.StreamPath(path), | 45 Path: types.StreamPath(path), |
| 46 Index: types.MessageIndex(index), | 46 Index: types.MessageIndex(index), |
| 47 Limit: limit, | 47 Limit: limit, |
| 48 KeysOnly: keysOnly, | 48 KeysOnly: keysOnly, |
| 49 } | 49 } |
| 50 got := []string{} | 50 got := []string{} |
| 51 err := s.Get(req, func(e *storage.Entry) bool { | 51 err := s.Get(req, func(e *storage.Entry) bool { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 }) | 249 }) |
| 250 | 250 |
| 251 Convey(`A tail request for "INVALID" errors NOT
FOUND.`, func() { | 251 Convey(`A tail request for "INVALID" errors NOT
FOUND.`, func() { |
| 252 _, err := tail("INVALID") | 252 _, err := tail("INVALID") |
| 253 So(err, ShouldEqual, storage.ErrDoesNotE
xist) | 253 So(err, ShouldEqual, storage.ErrDoesNotE
xist) |
| 254 }) | 254 }) |
| 255 }) | 255 }) |
| 256 }) | 256 }) |
| 257 }) | 257 }) |
| 258 } | 258 } |
| OLD | NEW |