go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/warmup/warmup_test.go (about) 1 // Copyright 2017 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 warmup 16 17 import ( 18 "context" 19 "fmt" 20 "testing" 21 22 . "github.com/smartystreets/goconvey/convey" 23 ) 24 25 func TestWorks(t *testing.T) { 26 Convey("Works", t, func() { 27 var called []string 28 29 Register("1", func(context.Context) error { 30 called = append(called, "1") 31 return nil 32 }) 33 34 Register("2", func(context.Context) error { 35 called = append(called, "2") 36 return fmt.Errorf("OMG 1") 37 }) 38 39 Register("3", func(context.Context) error { 40 called = append(called, "3") 41 return fmt.Errorf("OMG 2") 42 }) 43 44 err := Warmup(context.Background()) 45 So(err.Error(), ShouldEqual, "OMG 1 (and 1 other error)") 46 So(called, ShouldResemble, []string{"1", "2", "3"}) 47 }) 48 }