github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/internal/backends/java/msch_test.go (about) 1 package java 2 3 import ( 4 "testing" 5 ) 6 7 func TestSearchMavenCentral(t *testing.T) { 8 results, err := Search("junit") 9 10 if err != nil { 11 t.Errorf("Search failed with \n%q\n", err) 12 } 13 14 if len(results) != 10 { 15 t.Errorf("Only %q junit results found", len(results)) 16 } 17 18 for i := range results { 19 pkg := results[i] 20 if pkg.Artifact == "" { 21 t.Errorf("pkg %q has no name", pkg) 22 } 23 if pkg.Version == "" { 24 t.Errorf("pkg %q has no version", pkg) 25 } 26 } 27 } 28 29 func TestInfoMavenCentral(t *testing.T) { 30 pkg := "org.apache.logging.log4j:log4j-core" 31 info, err := Info(pkg) 32 33 if err != nil { 34 t.Errorf("Failed to find package with \n%q\n", err) 35 } 36 37 if info.CurrentVersion == "" { 38 t.Errorf("Did not find info for %q", pkg) 39 } 40 } 41 42 func TestInfoWithArtifactNameOnly(t *testing.T) { 43 artifact := "log4j-core" 44 info, err := Info(artifact) 45 46 if err != nil { 47 t.Errorf("Failed to find package with \n%q\n", err) 48 } 49 50 if info.CurrentVersion == "" { 51 t.Errorf("Did not find infor for %q", artifact) 52 } 53 } 54 55 func TestInfoWithUnknownArtifact(t *testing.T) { 56 artifact := "yyy" 57 _, err := Info(artifact) 58 59 if err != nil { 60 t.Errorf("Failed to find package with \n%q\n", err) 61 } 62 }