@@ -693,7 +693,6 @@ func TestCreateRequestParams(t *testing.T) {
693693 TestCommand : "rspec" ,
694694 },
695695 })
696-
697696 if err != nil {
698697 t .Errorf ("createRequestParam() error = %v" , err )
699698 }
@@ -778,7 +777,6 @@ func TestCreateRequestParams_NonRSpec(t *testing.T) {
778777 }
779778
780779 got , err := createRequestParam (context .Background (), & cfg , files , * client , r )
781-
782780 if err != nil {
783781 t .Errorf ("createRequestParam() error = %v" , err )
784782 }
@@ -838,7 +836,6 @@ func TestCreateRequestParams_PytestPants(t *testing.T) {
838836 }
839837
840838 got , err := createRequestParam (context .Background (), & cfg , files , * client , runner )
841-
842839 if err != nil {
843840 t .Errorf ("createRequestParam() error = %v" , err )
844841 }
@@ -935,7 +932,6 @@ func TestCreateRequestParams_NoFilteredFiles(t *testing.T) {
935932 TestCommand : "rspec" ,
936933 },
937934 })
938-
939935 if err != nil {
940936 t .Errorf ("createRequestParam() error = %v" , err )
941937 }
@@ -962,6 +958,122 @@ func TestCreateRequestParams_NoFilteredFiles(t *testing.T) {
962958 }
963959}
964960
961+ func TestCreateRequestParams_WithTagFilters (t * testing.T ) {
962+ cfg := config.Config {
963+ OrganizationSlug : "my-org" ,
964+ SuiteSlug : "my-suite" ,
965+ Identifier : "identifier" ,
966+ Parallelism : 2 ,
967+ Branch : "main" ,
968+ TestRunner : "pytest" ,
969+ TagFilters : "team:frontend" ,
970+ }
971+
972+ client := api .NewClient (api.ClientConfig {
973+ ServerBaseUrl : "example.com" ,
974+ })
975+
976+ files := []string {
977+ "../runner/testdata/pytest/failed_test.py" ,
978+ "../runner/testdata/pytest/test_sample.py" ,
979+ "../runner/testdata/pytest/spells/test_expelliarmus.py" ,
980+ }
981+
982+ got , err := createRequestParam (context .Background (), & cfg , files , * client , runner.Pytest {
983+ RunnerConfig : runner.RunnerConfig {
984+ TestCommand : "pytest" ,
985+ TagFilters : "team:frontend" ,
986+ },
987+ })
988+ if err != nil {
989+ t .Errorf ("createRequestParam() error = %v" , err )
990+ }
991+
992+ want := api.TestPlanParams {
993+ Identifier : "identifier" ,
994+ Parallelism : 2 ,
995+ Branch : "main" ,
996+ Runner : "pytest" ,
997+ Tests : api.TestPlanParamsTest {
998+ Examples : []plan.TestCase {
999+ {
1000+ Format : "example" ,
1001+ Identifier : "runner/testdata/pytest/test_sample.py::test_happy" ,
1002+ Name : "test_happy" ,
1003+ Path : "runner/testdata/pytest/test_sample.py::test_happy" ,
1004+ Scope : "runner/testdata/pytest/test_sample.py" ,
1005+ },
1006+ {
1007+ Format : "example" ,
1008+ Identifier : "runner/testdata/pytest/spells/test_expelliarmus.py::TestExpelliarmus::test_knocks_wand_out" ,
1009+ Name : "test_knocks_wand_out" ,
1010+ Path : "runner/testdata/pytest/spells/test_expelliarmus.py::TestExpelliarmus::test_knocks_wand_out" ,
1011+ Scope : "runner/testdata/pytest/spells/test_expelliarmus.py::TestExpelliarmus" ,
1012+ },
1013+ },
1014+ },
1015+ }
1016+
1017+ if diff := cmp .Diff (got , want ); diff != "" {
1018+ t .Errorf ("createRequestParam() diff (-got +want):\n %s" , diff )
1019+ }
1020+ }
1021+
1022+ func TestCreateRequestParams_WithTagFilters_NonPytest (t * testing.T ) {
1023+ svr := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
1024+ fmt .Fprint (w , `
1025+ {
1026+ "tests": []
1027+ }` )
1028+ }))
1029+ defer svr .Close ()
1030+
1031+ cfg := config.Config {
1032+ OrganizationSlug : "my-org" ,
1033+ SuiteSlug : "my-suite" ,
1034+ Identifier : "identifier" ,
1035+ Parallelism : 2 ,
1036+ Branch : "main" ,
1037+ TestRunner : "rspec" ,
1038+ TagFilters : "team:frontend" ,
1039+ }
1040+
1041+ client := api .NewClient (api.ClientConfig {
1042+ ServerBaseUrl : svr .URL ,
1043+ })
1044+
1045+ files := []string {
1046+ "testdata/rspec/spec/fruits/apple_spec.rb" ,
1047+ "testdata/rspec/spec/fruits/banana_spec.rb" ,
1048+ }
1049+
1050+ got , err := createRequestParam (context .Background (), & cfg , files , * client , runner.Rspec {
1051+ RunnerConfig : runner.RunnerConfig {
1052+ TestCommand : "rspec" ,
1053+ },
1054+ })
1055+ if err != nil {
1056+ t .Errorf ("createRequestParam() error = %v" , err )
1057+ }
1058+
1059+ want := api.TestPlanParams {
1060+ Identifier : "identifier" ,
1061+ Parallelism : 2 ,
1062+ Branch : "main" ,
1063+ Runner : "rspec" ,
1064+ Tests : api.TestPlanParamsTest {
1065+ Files : []plan.TestCase {
1066+ {Path : "testdata/rspec/spec/fruits/apple_spec.rb" },
1067+ {Path : "testdata/rspec/spec/fruits/banana_spec.rb" },
1068+ },
1069+ },
1070+ }
1071+
1072+ if diff := cmp .Diff (got , want ); diff != "" {
1073+ t .Errorf ("createRequestParam() diff (-got +want):\n %s" , diff )
1074+ }
1075+ }
1076+
9651077func TestSendMetadata (t * testing.T ) {
9661078 originalVersion := version .Version
9671079 version .Version = "0.1.0"
@@ -1019,7 +1131,6 @@ func TestSendMetadata(t *testing.T) {
10191131 } else {
10201132 w .WriteHeader (http .StatusOK )
10211133 }
1022-
10231134 }))
10241135 defer svr .Close ()
10251136
@@ -1070,7 +1181,6 @@ func TestRunTestsWithRetry_NoTestCases_Success(t *testing.T) {
10701181 failOnNoTests := false
10711182
10721183 testResult , err := runTestsWithRetry (testRunner , & testCases , maxRetries , []plan.TestCase {}, & timeline , true , failOnNoTests )
1073-
10741184 if err != nil {
10751185 t .Errorf ("runTestsWithRetry(...) error = %v, want nil" , err )
10761186 }
0 commit comments