sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/pkg/gerrit/fakegerrit/fakegerrit_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package fakegerrit 18 19 import ( 20 "testing" 21 22 gerrit "github.com/andygrunwald/go-gerrit" 23 ) 24 25 func TestAddChange(t *testing.T) { 26 tests := []struct { 27 name string 28 }{ 29 { 30 name: "added properlly for new project", 31 }, 32 } 33 for _, tc := range tests { 34 t.Run(tc.name, func(t *testing.T) { 35 fg := NewFakeGerritClient() 36 change := gerrit.ChangeInfo{ChangeID: "1"} 37 fg.AddChange("testproject", &change) 38 39 if project, ok := fg.Projects["testproject"]; !ok { 40 t.Fatalf("project %s not properly added to fake gerrit client", "testproject") 41 } else { 42 if len(project.ChangeIDs) == 0 { 43 t.Fatalf("change not properly added to project") 44 } 45 } 46 }) 47 } 48 }