Добавлена поддержка тестов с f-тегом
Этот коммит содержится в:
		
							родитель
							
								
									fca7fb6e4a
								
							
						
					
					
						коммит
						3f03171dab
					
				
					 4 изменённых файлов: 106 добавлений и 0 удалений
				
			
		
							
								
								
									
										24
									
								
								Magefile.go
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								Magefile.go
									
										
									
									
									
								
							|  | @ -64,6 +64,30 @@ func TestSnippets() { | ||||||
| 		'`) | 		'`) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func TestTags() { | ||||||
|  | 	Bash(`sudo docker run -ti --rm \ | ||||||
|  | 		-h host \ | ||||||
|  | 		--net=bridge \ | ||||||
|  | 		-v /etc/localtime:/etc/localtime:ro \ | ||||||
|  | 		-v ` + GolangVolume + `:/usr/local/go:ro \ | ||||||
|  | 		\ | ||||||
|  | 		-v /gopath:/gopath:rw \ | ||||||
|  | 		-v ${PWD}:/app \ | ||||||
|  | 		\ | ||||||
|  | 		-e GOPATH=/gopath \ | ||||||
|  | 		-e GOCACHE=/gopath/gocache \ | ||||||
|  | 		\ | ||||||
|  | 		-w /app \ | ||||||
|  | 		-u 1000 \ | ||||||
|  | 		\ | ||||||
|  | 		--entrypoint=/bin/bash \ | ||||||
|  | 		\ | ||||||
|  | 		` + ImageName + " -c '" + `set -x; \ | ||||||
|  | 		godog run -f progress -c 4 \ | ||||||
|  | 			features/tags.feature \ | ||||||
|  | 		'`) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func Install() { | func Install() { | ||||||
| 	Bash(`sudo docker run -ti --rm \ | 	Bash(`sudo docker run -ti --rm \ | ||||||
| 		-h host \ | 		-h host \ | ||||||
|  |  | ||||||
|  | @ -125,3 +125,31 @@ Feature: tag filters | ||||||
|       """ |       """ | ||||||
|       a feature path "four" |       a feature path "four" | ||||||
|       """ |       """ | ||||||
|  | 
 | ||||||
|  |   Scenario: empty filter and scenarios with f-tag - are executed only | ||||||
|  |     Given a feature "normal.feature" file: | ||||||
|  |       """ | ||||||
|  |       Feature: f-tagged | ||||||
|  | 
 | ||||||
|  |         Scenario: one | ||||||
|  |           Given a feature path "one" | ||||||
|  | 
 | ||||||
|  |         Scenario: two | ||||||
|  |           Given a feature path "two" | ||||||
|  | 
 | ||||||
|  |         @f | ||||||
|  |         Scenario: three | ||||||
|  |           Given a feature path "three" | ||||||
|  | 
 | ||||||
|  |         @f | ||||||
|  |         Scenario: four | ||||||
|  |           Given a feature path "four" | ||||||
|  |       """ | ||||||
|  |     When I run feature suite with tags "" | ||||||
|  |     Then the suite should have passed | ||||||
|  |     And I should have 2 scenario registered | ||||||
|  |     And the following steps should be passed: | ||||||
|  |       """ | ||||||
|  |       a feature path "three" | ||||||
|  |       a feature path "four" | ||||||
|  |       """ | ||||||
|  |  | ||||||
|  | @ -10,6 +10,11 @@ import ( | ||||||
| // array of pickles and returned the filtered list. | // array of pickles and returned the filtered list. | ||||||
| func ApplyTagFilter(filter string, pickles []*messages.Pickle) []*messages.Pickle { | func ApplyTagFilter(filter string, pickles []*messages.Pickle) []*messages.Pickle { | ||||||
| 	if filter == "" { | 	if filter == "" { | ||||||
|  | 		ff := filterF(pickles) | ||||||
|  | 		if len(ff) > 0 { | ||||||
|  | 			return ff | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		return pickles | 		return pickles | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -60,3 +65,15 @@ func contains(tags []*messages.PickleTag, tag string) bool { | ||||||
| 
 | 
 | ||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func filterF(pickles []*messages.Pickle) []*messages.Pickle { | ||||||
|  | 	var result = []*messages.Pickle{} | ||||||
|  | 
 | ||||||
|  | 	for _, pickle := range pickles { | ||||||
|  | 		if contains(pickle.Tags, "f") { | ||||||
|  | 			result = append(result, pickle) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return result | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										37
									
								
								internal/tags/tag_filter_f_test.go
									
										
									
									
									
										Обычный файл
									
								
							
							
						
						
									
										37
									
								
								internal/tags/tag_filter_f_test.go
									
										
									
									
									
										Обычный файл
									
								
							|  | @ -0,0 +1,37 @@ | ||||||
|  | package tags_test | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"testing" | ||||||
|  | 
 | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
|  | 
 | ||||||
|  | 	"github.com/cucumber/godog/internal/tags" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | type testcaseF struct { | ||||||
|  | 	filter   string | ||||||
|  | 	input    []*pickle | ||||||
|  | 	expected []*pickle | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | var testdataNonF = []*pickle{p1n, p2n, p3n} | ||||||
|  | var testdataF = []*pickle{p1n, p2n, p3withF} | ||||||
|  | var p1n = &pickle{Id: "one", Tags: []*tag{}} | ||||||
|  | var p2n = &pickle{Id: "two", Tags: []*tag{{Name: "@wip"}}} | ||||||
|  | var p3n = &pickle{Id: "three", Tags: []*tag{}} | ||||||
|  | var p3withF = &pickle{Id: "three", Tags: []*tag{{Name: "@f"}}} | ||||||
|  | 
 | ||||||
|  | var testcasesF = []testcaseF{ | ||||||
|  | 	{filter: "", input: testdataNonF, expected: testdataNonF}, | ||||||
|  | 	{filter: "", input: testdataF, expected: []*pickle{p3withF}}, | ||||||
|  | 	{filter: "@wip", input: testdataF, expected: []*pickle{p2n}}, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func Test_ApplyTagFilterWithF(t *testing.T) { | ||||||
|  | 	for _, tc := range testcasesF { | ||||||
|  | 		t.Run("", func(t *testing.T) { | ||||||
|  | 			actual := tags.ApplyTagFilter(tc.filter, tc.input) | ||||||
|  | 			assert.Equal(t, tc.expected, actual) | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 Softonik
						Softonik