go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/resultdb/internal/services/bqexporter/text_artifact_row_test.go (about) 1 // Copyright 2021 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 bqexporter 16 17 import ( 18 "fmt" 19 "testing" 20 21 "go.chromium.org/luci/common/clock/testclock" 22 23 "go.chromium.org/luci/resultdb/pbutil" 24 bqpb "go.chromium.org/luci/resultdb/proto/bq" 25 pb "go.chromium.org/luci/resultdb/proto/v1" 26 27 . "github.com/smartystreets/goconvey/convey" 28 ) 29 30 func TestGenerateArtifactBQRow(t *testing.T) { 31 t.Parallel() 32 33 Convey("GenerateBQRow", t, func() { 34 input := &textArtifactRowInput{ 35 exported: &pb.Invocation{ 36 Name: "invocations/exported", 37 CreateTime: pbutil.MustTimestampProto(testclock.TestRecentTimeUTC), 38 Realm: "testproject:testrealm", 39 }, 40 parent: &pb.Invocation{ 41 Name: "invocations/parent", 42 }, 43 a: &pb.Artifact{ 44 Name: "invocations/a/tests/ninja:%2F%2Fchrome%2Ftest:foo_tests%2FBarTest.DoBaz/results/result5/artifacts/a", 45 SizeBytes: 2e7, 46 }, 47 shardID: 0, 48 content: "deadbeef", 49 } 50 row := input.row() 51 actual, ok := row.(*bqpb.TextArtifactRowLegacy) 52 So(ok, ShouldBeTrue) 53 So(actual.Content, ShouldResemble, input.content) 54 55 So(input.id(), ShouldResemble, []byte(fmt.Sprintf("%s/%d", input.a.Name, input.shardID))) 56 }) 57 }