github.com/quay/claircore@v1.5.28/aws/internal/alas/updates_test.go (about) 1 // Copyright 2019 RedHat 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 alas 16 17 import ( 18 "encoding/xml" 19 "os" 20 "path/filepath" 21 "testing" 22 ) 23 24 func Test_Updates_Parse(t *testing.T) { 25 path := filepath.Join("testdata", "test_updateinfo.xml") 26 f, err := os.Open(path) 27 if err != nil { 28 t.Fatalf("failed to open test data: %v", err) 29 } 30 31 updates := &Updates{} 32 err = xml.NewDecoder(f).Decode(updates) 33 if err != nil { 34 t.Fatalf("failed to parse updateinfo test data into struct: %v", err) 35 } 36 37 if got, want := len(updates.Updates), 1170; got != want { 38 t.Errorf("unexpected number of updates: got: %d, want: %d", got, want) 39 } 40 }