pboling commented on code in PR #255:
URL: https://github.com/apache/skywalking-eyes/pull/255#discussion_r2636540034
##########
pkg/deps/ruby_test.go:
##########
@@ -117,6 +117,81 @@ func TestRubyGemfileLockResolver(t *testing.T) {
t.Fatalf("expected 1 dependency for library, got %d",
len(report.Resolved)+len(report.Skipped))
}
}
+
+ // Citrus case: library with gemspec, no runtime deps
+ {
+ tmp := t.TempDir()
+ if err := copyRuby("testdata/ruby/citrus", tmp); err != nil {
+ t.Fatal(err)
+ }
+ lock := filepath.Join(tmp, "Gemfile.lock")
+ if !resolver.CanResolve(lock) {
+ t.Fatalf("GemfileLockResolver cannot resolve %s", lock)
+ }
+ cfg := &ConfigDeps{Files: []string{lock}}
+ report := Report{}
+ if err := resolver.Resolve(lock, cfg, &report); err != nil {
+ t.Fatal(err)
+ }
+ // Should have 0 dependencies because citrus has no runtime deps
+ if len(report.Resolved)+len(report.Skipped) != 0 {
+ t.Fatalf("expected 0 dependencies, got %d",
len(report.Resolved)+len(report.Skipped))
+ }
+ }
+
+ // Local dependency case: App depends on local gem (citrus)
+ {
+ tmp := t.TempDir()
+ if err := copyRuby("testdata/ruby/local_dep", tmp); err != nil {
+ t.Fatal(err)
+ }
+ lock := filepath.Join(tmp, "Gemfile.lock")
+ if !resolver.CanResolve(lock) {
+ t.Fatalf("GemfileLockResolver cannot resolve %s", lock)
+ }
+ cfg := &ConfigDeps{Files: []string{lock}}
+ report := Report{}
+ if err := resolver.Resolve(lock, cfg, &report); err != nil {
+ t.Fatal(err)
+ }
+
+ // We expect citrus to be resolved with MIT license.
+ // This validates that local path dependencies are correctly
resolved.
+ found := false
+ for _, r := range report.Resolved {
+ if r.Dependency == "citrus" {
+ found = true
+ if r.LicenseSpdxID != "MIT" {
+ t.Errorf("expected MIT license for
citrus, got %s", r.LicenseSpdxID)
+ }
+ }
+ }
+ // Also check Skipped if it failed
+ for _, r := range report.Skipped {
+ if strings.HasPrefix(r.Dependency, "citrus") {
+ // Historically citrus landed here; keep this
check to ensure it no longer appears in Skipped with Unknown license.
+ t.Logf("citrus found in Skipped with license
%s", r.LicenseSpdxID)
+ if r.LicenseSpdxID == "Unknown" {
+ t.Errorf("citrus license is Unknown")
+ }
+ }
+ }
+
+ if !found {
+ // If it's in Skipped, found is false.
+ // We want it to be in Resolved.
+ // But for now, let's just assert it is present in
either.
+ inSkipped := false
+ for _, r := range report.Skipped {
+ if strings.HasPrefix(r.Dependency, "citrus") {
+ inSkipped = true
+ }
+ }
+ if !inSkipped {
+ t.Fatal("expected citrus to be in the report")
+ }
+ }
Review Comment:
Fixed in c84b648
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]