| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | package defaults | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2017-04-22 10:21:23 -03:00
										 |  |  | 	"io/ioutil" | 
					
						
							|  |  |  | 	"os" | 
					
						
							| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 20:01:32 -02:00
										 |  |  | 	"github.com/goreleaser/goreleaser/config" | 
					
						
							|  |  |  | 	"github.com/goreleaser/goreleaser/context" | 
					
						
							| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | 	"github.com/stretchr/testify/assert" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 20:43:42 -03:00
										 |  |  | func TestDescription(t *testing.T) { | 
					
						
							|  |  |  | 	assert.NotEmpty(t, Pipe{}.Description()) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | func TestFillBasicData(t *testing.T) { | 
					
						
							|  |  |  | 	assert := assert.New(t) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var ctx = &context.Context{ | 
					
						
							| 
									
										
										
										
											2017-01-18 15:08:48 -02:00
										 |  |  | 		Config: config.Project{}, | 
					
						
							| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	assert.NoError(Pipe{}.Run(ctx)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-22 21:01:29 -03:00
										 |  |  | 	assert.Equal("goreleaser", ctx.Config.Release.GitHub.Owner) | 
					
						
							|  |  |  | 	assert.Equal("goreleaser", ctx.Config.Release.GitHub.Name) | 
					
						
							| 
									
										
										
										
											2017-03-22 21:06:37 -03:00
										 |  |  | 	assert.Equal("goreleaser", ctx.Config.Build.Binary) | 
					
						
							| 
									
										
										
										
											2017-02-26 13:01:48 -03:00
										 |  |  | 	assert.Equal(".", ctx.Config.Build.Main) | 
					
						
							| 
									
										
										
										
											2017-01-18 15:08:48 -02:00
										 |  |  | 	assert.Equal("tar.gz", ctx.Config.Archive.Format) | 
					
						
							|  |  |  | 	assert.Contains(ctx.Config.Build.Goos, "darwin") | 
					
						
							|  |  |  | 	assert.Contains(ctx.Config.Build.Goos, "linux") | 
					
						
							|  |  |  | 	assert.Contains(ctx.Config.Build.Goarch, "386") | 
					
						
							|  |  |  | 	assert.Contains(ctx.Config.Build.Goarch, "amd64") | 
					
						
							| 
									
										
										
										
											2017-03-09 16:33:17 -03:00
										 |  |  | 	assert.Contains(ctx.Config.Brew.Install, "bin.install \"goreleaser\"") | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 	assert.NotEmpty( | 
					
						
							| 
									
										
										
										
											2017-01-18 15:08:48 -02:00
										 |  |  | 		ctx.Config.Archive.Replacements, | 
					
						
							|  |  |  | 		ctx.Config.Archive.NameTemplate, | 
					
						
							|  |  |  | 		ctx.Config.Build.Ldflags, | 
					
						
							|  |  |  | 		ctx.Config.Archive.Files, | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 	) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func TestFilesFilled(t *testing.T) { | 
					
						
							|  |  |  | 	assert := assert.New(t) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-18 15:08:48 -02:00
										 |  |  | 	var ctx = &context.Context{ | 
					
						
							|  |  |  | 		Config: config.Project{ | 
					
						
							|  |  |  | 			Archive: config.Archive{ | 
					
						
							|  |  |  | 				Files: []string{ | 
					
						
							|  |  |  | 					"README.md", | 
					
						
							|  |  |  | 				}, | 
					
						
							| 
									
										
										
										
											2017-01-14 19:52:39 -02:00
										 |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	assert.NoError(Pipe{}.Run(ctx)) | 
					
						
							| 
									
										
										
										
											2017-01-18 15:08:48 -02:00
										 |  |  | 	assert.Len(ctx.Config.Archive.Files, 1) | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func TestAcceptFiles(t *testing.T) { | 
					
						
							|  |  |  | 	var files = []string{ | 
					
						
							|  |  |  | 		"LICENSE.md", | 
					
						
							| 
									
										
										
										
											2017-01-14 15:17:03 -02:00
										 |  |  | 		"LIceNSE.txt", | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 		"LICENSE", | 
					
						
							|  |  |  | 		"LICENCE.txt", | 
					
						
							| 
									
										
										
										
											2017-01-14 15:17:03 -02:00
										 |  |  | 		"LICEncE", | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 		"README", | 
					
						
							| 
									
										
										
										
											2017-01-14 15:17:03 -02:00
										 |  |  | 		"READme.md", | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 		"CHANGELOG.txt", | 
					
						
							| 
									
										
										
										
											2017-01-14 15:17:03 -02:00
										 |  |  | 		"ChanGELOG.md", | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for _, file := range files { | 
					
						
							| 
									
										
										
										
											2017-02-26 13:01:48 -03:00
										 |  |  | 		t.Run(file, func(t *testing.T) { | 
					
						
							|  |  |  | 			assert.True(t, accept(file)) | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2017-01-14 14:38:48 -02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-14 14:29:01 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-22 10:21:23 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | func TestNotAGitRepo(t *testing.T) { | 
					
						
							|  |  |  | 	var assert = assert.New(t) | 
					
						
							|  |  |  | 	folder, err := ioutil.TempDir("", "goreleasertest") | 
					
						
							|  |  |  | 	assert.NoError(err) | 
					
						
							|  |  |  | 	previous, err := os.Getwd() | 
					
						
							|  |  |  | 	assert.NoError(err) | 
					
						
							|  |  |  | 	assert.NoError(os.Chdir(folder)) | 
					
						
							|  |  |  | 	defer func() { | 
					
						
							|  |  |  | 		assert.NoError(os.Chdir(previous)) | 
					
						
							|  |  |  | 	}() | 
					
						
							|  |  |  | 	var ctx = &context.Context{ | 
					
						
							|  |  |  | 		Config: config.Project{}, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	assert.Error(Pipe{}.Run(ctx)) | 
					
						
							|  |  |  | } |