go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/logdog/common/storage/bigtable/bigtable_test.go (about) 1 // Copyright 2015 The LUCI Authors. 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 bigtable 16 17 import ( 18 "testing" 19 20 "go.chromium.org/luci/logdog/common/storage" 21 22 "cloud.google.com/go/bigtable" 23 24 . "github.com/smartystreets/goconvey/convey" 25 ) 26 27 func TestBigTable(t *testing.T) { 28 t.Parallel() 29 30 Convey(`Testing BigTable internal functions`, t, func() { 31 s := NewMemoryInstance(nil) 32 defer s.Close() 33 34 Convey(`Given a fake BigTable row`, func() { 35 fakeRow := bigtable.Row{ 36 "log": []bigtable.ReadItem{ 37 { 38 Row: "testrow", 39 Column: logColName, 40 Value: []byte("here is my data"), 41 }, 42 }, 43 } 44 45 Convey(`Can extract log data.`, func() { 46 d, err := getLogRowData(fakeRow) 47 So(err, ShouldBeNil) 48 So(d, ShouldResemble, []byte("here is my data")) 49 }) 50 51 Convey(`Will fail to extract if the column is missing.`, func() { 52 fakeRow["log"][0].Column = "not-data" 53 54 _, err := getLogRowData(fakeRow) 55 So(err, ShouldEqual, storage.ErrDoesNotExist) 56 }) 57 58 Convey(`Will fail to extract if the family does not exist.`, func() { 59 So(getReadItem(fakeRow, "invalid", "invalid"), ShouldBeNil) 60 }) 61 62 Convey(`Will fail to extract if the column does not exist.`, func() { 63 So(getReadItem(fakeRow, "log", "invalid"), ShouldBeNil) 64 }) 65 }) 66 67 }) 68 }