github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/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(t, ctx.Config.Archive.NameTemplate) 41 assert.NotEmpty(t, ctx.Config.Builds[0].Ldflags) 42 assert.NotEmpty(t, ctx.Config.Archive.Files) 43 assert.NotEmpty(t, ctx.Config.Dist) 44 } 45 46 func TestFillPartial(t *testing.T) { 47 _, back := testlib.Mktmp(t) 48 defer back() 49 testlib.GitInit(t) 50 testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git") 51 52 var ctx = &context.Context{ 53 Config: config.Project{ 54 GitHubURLs: config.GitHubURLs{ 55 Download: "https://github.company.com", 56 }, 57 Dist: "disttt", 58 Release: config.Release{ 59 GitHub: config.Repo{ 60 Owner: "goreleaser", 61 Name: "test", 62 }, 63 }, 64 Archive: config.Archive{ 65 Files: []string{ 66 "glob/*", 67 }, 68 }, 69 Builds: []config.Build{ 70 {Binary: "testreleaser"}, 71 {Goos: []string{"linux"}}, 72 { 73 Binary: "another", 74 Ignore: []config.IgnoredBuild{ 75 {Goos: "darwin", Goarch: "amd64"}, 76 }, 77 }, 78 }, 79 Dockers: []config.Docker{ 80 {Image: "a/b"}, 81 }, 82 }, 83 } 84 assert.NoError(t, Pipe{}.Run(ctx)) 85 assert.Len(t, ctx.Config.Archive.Files, 1) 86 assert.Equal(t, `bin.install "testreleaser"`, ctx.Config.Brew.Install) 87 assert.NotEmpty(t, ctx.Config.Dockers[0].Binary) 88 assert.NotEmpty(t, ctx.Config.Dockers[0].Goos) 89 assert.NotEmpty(t, ctx.Config.Dockers[0].Goarch) 90 assert.NotEmpty(t, ctx.Config.Dockers[0].Dockerfile) 91 assert.Empty(t, ctx.Config.Dockers[0].Goarm) 92 assert.Equal(t, "disttt", ctx.Config.Dist) 93 assert.NotEqual(t, "https://github.com", ctx.Config.GitHubURLs.Download) 94 }