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

     1  package testSuite
     2  
     3  import (
     4  	"testing"
     5  
     6  	testUtils "github.com/replit/upm/test-suite/utils"
     7  )
     8  
     9  func TestAdd(t *testing.T) {
    10  	for _, bt := range languageBackends {
    11  		bt.Start(t)
    12  
    13  		var pkgs []string
    14  		switch bt.Backend.Name {
    15  		case "nodejs-npm":
    16  			fallthrough
    17  		case "nodejs-pnpm":
    18  			fallthrough
    19  		case "nodejs-yarn":
    20  			fallthrough
    21  		case "bun":
    22  			pkgs = []string{"lodash", "react", "@replit/protocol"}
    23  
    24  		case "python3-poetry", "python3-pip":
    25  			pkgs = []string{"replit-ai", "flask >=2", "pyyaml", "discord-py 2.3.2"}
    26  
    27  		default:
    28  			t.Run(bt.Backend.Name, func(t *testing.T) {
    29  				t.Skip("no test")
    30  			})
    31  			continue
    32  		}
    33  
    34  		bt.Subtest(bt.Backend.Name, func(bt testUtils.BackendT) {
    35  			doAdd(bt, pkgs...)
    36  		})
    37  	}
    38  }
    39  
    40  func doAdd(bt testUtils.BackendT, pkgs ...string) {
    41  	for _, tmpl := range standardTemplates {
    42  		template := bt.Backend.Name + "/" + tmpl + "/"
    43  
    44  		if tmpl != "no-deps" {
    45  			bt.Subtest(tmpl, func(bt testUtils.BackendT) {
    46  				if bt.Backend.QuirksIsReproducible() {
    47  					bt.Subtest("locked", func(bt testUtils.BackendT) {
    48  						bt.Subtest("each", func(bt testUtils.BackendT) {
    49  							bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
    50  							bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
    51  							for _, pkg := range pkgs {
    52  								bt.UpmAdd(pkg)
    53  							}
    54  						})
    55  
    56  						bt.Subtest("all", func(bt testUtils.BackendT) {
    57  							bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
    58  							bt.AddTestFile(template+bt.Backend.Lockfile, bt.Backend.Lockfile)
    59  							bt.UpmAdd(pkgs...)
    60  						})
    61  					})
    62  				}
    63  
    64  				bt.Subtest("unlocked", func(bt testUtils.BackendT) {
    65  					bt.Subtest("each", func(bt testUtils.BackendT) {
    66  						bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
    67  						for _, pkg := range pkgs {
    68  							bt.UpmAdd(pkg)
    69  						}
    70  					})
    71  
    72  					bt.Subtest("all", func(bt testUtils.BackendT) {
    73  						bt.AddTestFile(template+bt.Backend.Specfile, bt.Backend.Specfile)
    74  						bt.UpmAdd(pkgs...)
    75  					})
    76  				})
    77  			})
    78  		}
    79  	}
    80  }