| 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 "testing" | 8 "testing" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| 11 "cloud.google.com/go/bigtable" | 11 "cloud.google.com/go/bigtable" |
| 12 "github.com/luci/luci-go/common/errors" | 12 "github.com/luci/luci-go/common/errors" |
| 13 "github.com/luci/luci-go/logdog/common/storage" | 13 "github.com/luci/luci-go/logdog/common/storage" |
| 14 "golang.org/x/net/context" | 14 "golang.org/x/net/context" |
| 15 | 15 |
| 16 . "github.com/smartystreets/goconvey/convey" | 16 . "github.com/smartystreets/goconvey/convey" |
| 17 ) | 17 ) |
| 18 | 18 |
| 19 func TestBigTable(t *testing.T) { | 19 func TestBigTable(t *testing.T) { |
| 20 t.Parallel() | 20 t.Parallel() |
| 21 | 21 |
| 22 Convey(`Testing BigTable internal functions`, t, func() { | 22 Convey(`Testing BigTable internal functions`, t, func() { |
| 23 » » var bt btTableTest | 23 » » s := NewMemoryInstance(context.Background(), Options{}) |
| 24 » » defer bt.close() | |
| 25 | |
| 26 » » s := newBTStorage(context.Background(), Options{ | |
| 27 » » » Project: "test-project", | |
| 28 » » » Instance: "test-instance", | |
| 29 » » » LogTable: "test-log-table", | |
| 30 » » }, nil, nil) | |
| 31 | |
| 32 » » s.raw = &bt | |
| 33 defer s.Close() | 24 defer s.Close() |
| 34 | 25 |
| 35 Convey(`Given a fake BigTable row`, func() { | 26 Convey(`Given a fake BigTable row`, func() { |
| 36 fakeRow := bigtable.Row{ | 27 fakeRow := bigtable.Row{ |
| 37 "log": []bigtable.ReadItem{ | 28 "log": []bigtable.ReadItem{ |
| 38 { | 29 { |
| 39 Row: "testrow", | 30 Row: "testrow", |
| 40 Column: logColName, | 31 Column: logColName, |
| 41 Value: []byte("here is my data"
), | 32 Value: []byte("here is my data"
), |
| 42 }, | 33 }, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 }) | 56 }) |
| 66 }) | 57 }) |
| 67 | 58 |
| 68 Convey(`When pushing a configuration`, func() { | 59 Convey(`When pushing a configuration`, func() { |
| 69 cfg := storage.Config{ | 60 cfg := storage.Config{ |
| 70 MaxLogAge: 1 * time.Hour, | 61 MaxLogAge: 1 * time.Hour, |
| 71 } | 62 } |
| 72 | 63 |
| 73 Convey(`Can successfully apply configuration.`, func() { | 64 Convey(`Can successfully apply configuration.`, func() { |
| 74 So(s.Config(cfg), ShouldBeNil) | 65 So(s.Config(cfg), ShouldBeNil) |
| 75 » » » » So(bt.maxLogAge, ShouldEqual, cfg.MaxLogAge) | 66 » » » » So(s.MaxLogAge(), ShouldEqual, cfg.MaxLogAge) |
| 76 }) | 67 }) |
| 77 | 68 |
| 78 Convey(`With return an error if the configuration fails
to apply.`, func() { | 69 Convey(`With return an error if the configuration fails
to apply.`, func() { |
| 79 » » » » bt.err = errors.New("test error") | 70 » » » » testErr := errors.New("test error") |
| 71 » » » » s.SetErr(testErr) |
| 80 | 72 |
| 81 » » » » So(s.Config(cfg), ShouldEqual, bt.err) | 73 » » » » So(s.Config(cfg), ShouldEqual, testErr) |
| 82 }) | 74 }) |
| 83 }) | 75 }) |
| 84 }) | 76 }) |
| 85 } | 77 } |
| OLD | NEW |