go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/internal/services/reclustering/reclustering_test.go (about) 1 // Copyright 2022 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 reclustering 16 17 import ( 18 "strings" 19 "testing" 20 "time" 21 22 "google.golang.org/protobuf/proto" 23 "google.golang.org/protobuf/types/known/timestamppb" 24 25 "go.chromium.org/luci/server/tq" 26 27 "go.chromium.org/luci/analysis/internal/tasks/taskspb" 28 "go.chromium.org/luci/analysis/internal/testutil" 29 30 _ "go.chromium.org/luci/server/tq/txn/spanner" 31 32 . "github.com/smartystreets/goconvey/convey" 33 . "go.chromium.org/luci/common/testing/assertions" 34 ) 35 36 func TestSchedule(t *testing.T) { 37 Convey(`TestSchedule`, t, func() { 38 ctx, skdr := tq.TestingContext(testutil.TestingContext(), nil) 39 40 task := &taskspb.ReclusterChunks{ 41 Project: "chromium", 42 AttemptTime: timestamppb.New(time.Date(2025, time.January, 1, 12, 0, 0, 0, time.UTC)), 43 StartChunkId: "", 44 EndChunkId: strings.Repeat("ff", 16), 45 } 46 expected := proto.Clone(task).(*taskspb.ReclusterChunks) 47 So(Schedule(ctx, task), ShouldBeNil) 48 So(skdr.Tasks().Payloads()[0], ShouldResembleProto, expected) 49 }) 50 }