Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Update dependency check #221

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,23 @@ func TestApplicationAnalysis(t *testing.T) {
sort.SliceStable(gotAnalysis.Dependencies, func(a, b int) bool { return gotAnalysis.Dependencies[a].Name < gotAnalysis.Dependencies[b].Name })
sort.SliceStable(tc.Analysis.Dependencies, func(a, b int) bool { return tc.Analysis.Dependencies[a].Name < tc.Analysis.Dependencies[b].Name })

// Check the dependencies (if specified by TestCase).
if len(tc.Analysis.Dependencies) > 0 {
if len(gotAnalysis.Dependencies) != len(tc.Analysis.Dependencies) {
t.Errorf("Different amount of dependencies error. Got %d, expected %d.", len(gotAnalysis.Dependencies), len(tc.Analysis.Dependencies))
t.Error("Got:")
pp.Println(gotAnalysis.Dependencies)
t.Error("Expected:")
pp.Println(tc.Analysis.Dependencies)
} else {
for i, got := range gotAnalysis.Dependencies {
expected := tc.Analysis.Dependencies[i]
if got.Name != expected.Name || got.Version != expected.Version || got.Provider != expected.Provider {
t.Errorf("\nDifferent dependency error. Got %+v\nExpected %+v.\n\n", got, expected)
}
// Check dependencies
if (len(gotAnalysis.Dependencies) == 0 && len(tc.Analysis.Dependencies) == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (len(gotAnalysis.Dependencies) == 0 && len(tc.Analysis.Dependencies) == 0) {
if tc.Analysis.Dependencies != nil {

t.Log("Skipping Dependencies check, Got=Expected=0.")
} else if len(gotAnalysis.Dependencies) != len(tc.Analysis.Dependencies) {
t.Errorf("Different amount of dependencies error. Got %d, expected %d.", len(gotAnalysis.Dependencies), len(tc.Analysis.Dependencies))
t.Error("Got:")
pp.Println(gotAnalysis.Dependencies)
t.Error("Expected:")
pp.Println(tc.Analysis.Dependencies)
} else {
// if len(gotAnalysis.Dependencies) = len(tc.Analysis.Dependencies)
for i, got := range gotAnalysis.Dependencies {
expected := tc.Analysis.Dependencies[i]
if got.Name != expected.Name || got.Version != expected.Version || got.Provider != expected.Provider {
t.Errorf("\nDifferent dependency error. Got %+v\nExpected %+v.\n\n", got, expected)
}
}
} else {
t.Log("Skipping Dependencies check, nothing is expected.")
}

// Check analysis-created Tags.
Expand Down
Loading