github.com/drone/runner-go@v1.12.0/registry/combine_test.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Polyform License 3 // that can be found in the LICENSE file. 4 5 package registry 6 7 import ( 8 "errors" 9 "testing" 10 11 "github.com/drone/drone-go/drone" 12 ) 13 14 func TestCombine(t *testing.T) { 15 a := &drone.Registry{} 16 b := &drone.Registry{} 17 aa := mockProvider{out: []*drone.Registry{a}} 18 bb := mockProvider{out: []*drone.Registry{b}} 19 p := Combine(&aa, &bb) 20 out, err := p.List(noContext, nil) 21 if err != nil { 22 t.Error(err) 23 return 24 } 25 if len(out) != 2 { 26 t.Errorf("Expect combined registry output") 27 return 28 } 29 if out[0] != a { 30 t.Errorf("Unexpected registry at index 0") 31 } 32 if out[1] != b { 33 t.Errorf("Unexpected registry at index 1") 34 } 35 } 36 37 func TestCombineError(t *testing.T) { 38 e := errors.New("not found") 39 m := mockProvider{err: e} 40 p := Combine(&m) 41 _, err := p.List(noContext, nil) 42 if err != e { 43 t.Errorf("Expect error") 44 } 45 }