github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/test-suite/Search_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 TestSearch(t *testing.T) {
    10  	for _, bt := range languageBackends {
    11  		bt.Start(t)
    12  
    13  		switch bt.Backend.Name {
    14  		case "nodejs-npm":
    15  			fallthrough
    16  		case "nodejs-pnpm":
    17  			fallthrough
    18  		case "nodejs-yarn":
    19  			fallthrough
    20  		case "bun":
    21  			doSearch(bt, []searchTest{
    22  				{"express", "express"},
    23  				{"@replit/crosis", "@replit/crosis"},
    24  				{"@replit", "@replit/crosis"},
    25  			})
    26  
    27  		case "python3-poetry", "python3-pip":
    28  			doSearch(bt, []searchTest{
    29  				{"flask", "Flask"},
    30  				{"replit-ai", "replit-ai"},
    31  				{"replit", "replit-ai"},
    32  			})
    33  
    34  		default:
    35  			t.Run(bt.Backend.Name, func(t *testing.T) {
    36  				t.Skip("no test")
    37  			})
    38  			continue
    39  		}
    40  	}
    41  }
    42  
    43  type searchTest struct {
    44  	query    string
    45  	expected string
    46  }
    47  
    48  func doSearch(t testUtils.BackendT, tests []searchTest) {
    49  	t.Subtest(t.Backend.Name, func(t testUtils.BackendT) {
    50  		for _, test := range tests {
    51  			t.Subtest(test.query, func(t testUtils.BackendT) {
    52  				t.UpmSearch(test.query, test.expected)
    53  			})
    54  		}
    55  	})
    56  }