github.com/droot/goreleaser@v0.66.2-0.20180420030140-c2db5fb17157/pipeline/defaults/defaults_test.go (about) 1 package defaults 2 3 import ( 4 "testing" 5 6 "github.com/goreleaser/goreleaser/config" 7 "github.com/goreleaser/goreleaser/context" 8 "github.com/goreleaser/goreleaser/internal/testlib" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestDescription(t *testing.T) { 13 assert.NotEmpty(t, Pipe{}.String()) 14 } 15 16 func TestFillBasicData(t *testing.T) { 17 _, back := testlib.Mktmp(t) 18 defer back() 19 testlib.GitInit(t) 20 testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git") 21 22 var ctx = &context.Context{ 23 Config: config.Project{}, 24 } 25 26 assert.NoError(t, Pipe{}.Run(ctx)) 27 assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Owner) 28 assert.Equal(t, "goreleaser", ctx.Config.Release.GitHub.Name) 29 assert.NotEmpty(t, ctx.Config.Builds) 30 assert.Equal(t, "goreleaser", ctx.Config.Builds[0].Binary) 31 assert.Equal(t, ".", ctx.Config.Builds[0].Main) 32 assert.Contains(t, ctx.Config.Builds[0].Goos, "darwin") 33 assert.Contains(t, ctx.Config.Builds[0].Goos, "linux") 34 assert.Contains(t, ctx.Config.Builds[0].Goarch, "386") 35 assert.Contains(t, ctx.Config.Builds[0].Goarch, "amd64") 36 assert.Equal(t, "tar.gz", ctx.Config.Archive.Format) 37 assert.Contains(t, ctx.Config.Brew.Install, "bin.install \"goreleaser\"") 38 assert.Empty(t, ctx.Config.Dockers) 39 assert.Equal(t, "https://github.com", ctx.Config.GitHubURLs.Download) 40 assert.NotEmpty( 41 t, 42 ctx.Config.Archive.NameTemplate, 43 ctx.Config.Builds[0].Ldflags, 44 ctx.Config.Archive.Files, 45 ctx.Config.Dist, 46 ) 47 } 48 49 func TestFillPartial(t *testing.T) { 50 _, back := testlib.Mktmp(t) 51 defer back() 52 testlib.GitInit(t) 53 testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git") 54 55 var ctx = &context.Context{ 56 Config: config.Project{ 57 GitHubURLs: config.GitHubURLs{ 58 Download: "https://github.company.com", 59 }, 60 Dist: "disttt", 61 Release: config.Release{ 62 GitHub: config.Repo{ 63 Owner: "goreleaser", 64 Name: "test", 65 }, 66 }, 67 Archive: config.Archive{ 68 Files: []string{ 69 "glob/*", 70 }, 71 }, 72 Builds: []config.Build{ 73 {Binary: "testreleaser"}, 74 {Goos: []string{"linux"}}, 75 { 76 Binary: "another", 77 Ignore: []config.IgnoredBuild{ 78 {Goos: "darwin", Goarch: "amd64"}, 79 }, 80 }, 81 }, 82 Dockers: []config.Docker{ 83 {Image: "a/b"}, 84 }, 85 }, 86 } 87 assert.NoError(t, Pipe{}.Run(ctx)) 88 assert.Len(t, ctx.Config.Archive.Files, 1) 89 assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brew.Install) 90 assert.NotEmpty(t, ctx.Config.Dockers[0].Binary) 91 assert.NotEmpty(t, ctx.Config.Dockers[0].Goos) 92 assert.NotEmpty(t, ctx.Config.Dockers[0].Goarch) 93 assert.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile) 94 assert.Empty(t, ctx.Config.Dockers[0].Goarm) 95 assert.Equal(t, "disttt", ctx.Config.Dist) 96 assert.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download) 97 }