github.com/google/osv-scalibr@v0.4.1/guidedremediation/internal/manifest/python/python_test.go (about)

     1  // Copyright 2025 Google LLC
     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 python
    16  
    17  import (
    18  	"testing"
    19  
    20  	"deps.dev/util/resolve"
    21  	"github.com/google/go-cmp/cmp"
    22  	"github.com/google/osv-scalibr/guidedremediation/internal/manifest"
    23  )
    24  
    25  type testManifest struct {
    26  	FilePath     string
    27  	Root         resolve.Version
    28  	System       resolve.System
    29  	Requirements []resolve.RequirementVersion
    30  	Groups       map[manifest.RequirementKey][]string
    31  }
    32  
    33  func checkManifest(t *testing.T, name string, got manifest.Manifest, want testManifest) {
    34  	t.Helper()
    35  	if want.FilePath != got.FilePath() {
    36  		t.Errorf("%s.FilePath() = %q, want %q", name, got.FilePath(), want.FilePath)
    37  	}
    38  	if diff := cmp.Diff(want.Root, got.Root()); diff != "" {
    39  		t.Errorf("%s.Root() (-want +got):\n%s", name, diff)
    40  	}
    41  	if want.System != got.System() {
    42  		t.Errorf("%s.System() = %v, want %v", name, got.System(), want.System)
    43  	}
    44  	if diff := cmp.Diff(want.Requirements, got.Requirements()); diff != "" {
    45  		t.Errorf("%s.Requirements() (-want +got):\n%s", name, diff)
    46  	}
    47  	if diff := cmp.Diff(want.Groups, got.Groups()); diff != "" {
    48  		t.Errorf("%s.Groups() (-want +got):\n%s", name, diff)
    49  	}
    50  }