github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/test-suite/Install_test.go (about)

     1  package testSuite
     2  
     3  import (
     4  	"os"
     5  	"path"
     6  	"testing"
     7  
     8  	testUtils "github.com/replit/upm/test-suite/utils"
     9  )
    10  
    11  var testInstalls = map[string]bool{
    12  	"bun":            true,
    13  	"nodejs-npm":     true,
    14  	"nodejs-pnpm":    true,
    15  	"nodejs-yarn":    true,
    16  	"python3-poetry": true,
    17  	"python3-pip":    true,
    18  }
    19  
    20  func TestInstall(t *testing.T) {
    21  	for _, bt := range languageBackends {
    22  		bt.Start(t)
    23  
    24  		if !testInstalls[bt.Backend.Name] {
    25  			t.Run(bt.Backend.Name, func(t *testing.T) {
    26  				t.Skip("no test")
    27  			})
    28  			continue
    29  		}
    30  
    31  		bt.Subtest(bt.Backend.Name, doInstall)
    32  	}
    33  }
    34  
    35  func doInstall(bt testUtils.BackendT) {
    36  	for _, tmpl := range standardTemplates {
    37  		if tmpl == "no-deps" {
    38  			continue
    39  		}
    40  
    41  		template := bt.Backend.Name + "/" + tmpl + "/"
    42  		bt.Subtest(tmpl, func(bt testUtils.BackendT) {
    43  			bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
    44  			if bt.Backend.QuirksIsReproducible() {
    45  				bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
    46  			}
    47  
    48  			bt.UpmInstall()
    49  
    50  			packageDirPath := bt.UpmPackageDir()
    51  
    52  			if !path.IsAbs(packageDirPath) {
    53  				packageDirPath = path.Join(bt.TestDir(), packageDirPath)
    54  			}
    55  			_, err := os.Stat(packageDirPath)
    56  			if err != nil {
    57  				bt.Fail("expected package dir to exist: %v", err)
    58  			}
    59  		})
    60  	}
    61  }