Skip to content

Commit

Permalink
feat: add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
honzap committed Dec 12, 2024
1 parent 14a735c commit 8a4ea86
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
before:
hooks:
- make dep<nil>archives: []
checksum:
name_template: 'checksums.txt'
release:
# We handle releasing via semantic-release
disable: true
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
before:
hooks:
- make dep
builds:
- main: ./cmd/cmd1
id: &name cmd1
binary: *name
goos:
- linux
- darwin
goarch:
- arm64
- amd64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd1AdditionalEnv)>>

## <</Stencil::Block>>
- main: ./cmd/cmd2
id: &name cmd2
binary: *name
goos:
- linux
- darwin
goarch:
- arm64
- amd64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd2AdditionalEnv)>>

## <</Stencil::Block>>
- main: ./cmd/cmd3-sub1
id: &name cmd3-sub1
binary: *name
goos:
- linux
- darwin
goarch:
- arm64
- amd64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd3sub1AdditionalEnv)>>

## <</Stencil::Block>>
- main: ./cmd/cmd3-sub2
id: &name cmd3-sub2
binary: *name
goos:
- linux
- darwin
goarch:
- arm64
- amd64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd3sub2AdditionalEnv)>>

## <</Stencil::Block>>
- main: ./cmd/cmd4_sub1
id: &name cmd4_sub1
binary: *name
goos:
- linux
- darwin
goarch:
- arm64
- amd64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd4sub1AdditionalEnv)>>

## <</Stencil::Block>>archives: []
checksum:
name_template: 'checksums.txt'
release:
# We handle releasing via semantic-release
disable: true
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(*codegen.File)(# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
before:
hooks:
- make dep
builds:
- main: ./cmd/cmd1
id: &name cmd1
binary: *name
goos:
- linux
goarch:
- arm64
ldflags:
- '-w -s -X "github.com/getoutreach/gobox/pkg/app.Version=v{{ .Version }}"'
- '-X "main.HoneycombTracingKey={{ .Env.HONEYCOMB_APIKEY }}"'
- '-X "main.TeleforkAPIKey={{ .Env.TELEFORK_APIKEY }}"'
env:
- CGO_ENABLED=0
## <<Stencil::Block(cmd1AdditionalEnv)>>

## <</Stencil::Block>>archives: []
checksum:
name_template: 'checksums.txt'
release:
# We handle releasing via semantic-release
disable: true
)
60 changes: 57 additions & 3 deletions templates/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ func TestGRPCServerRPC(t *testing.T) {
"grpc",
},
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestGoreleaserYml(t *testing.T) {
func TestGoreleaserYmlOnlyCommands(t *testing.T) {
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
st.Args(map[string]interface{}{
"commands": []interface{}{
Expand All @@ -244,7 +244,61 @@ func TestGoreleaserYml(t *testing.T) {
"cmd4_sub1",
},
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestGoreleaserYmlWithBuildAsset(t *testing.T) {
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
st.Args(map[string]interface{}{
"commands": []any{
map[string]any{
"cmd1": map[string]any{
"buildAsset": true,
},
},
map[string]any{
"cmd2": map[string]any{
"buildAsset": true,
},
},
map[string]any{
"cmd3-sub1": map[string]any{
"buildAsset": true,
},
},
map[string]any{
"cmd3-sub2": map[string]any{
"buildAsset": true,
},
},
map[string]any{
"cmd4_sub1": map[string]any{
"buildAsset": true,
},
},
},
})
st.Run(stenciltest.RegenerateSnapshots())
}

func TestGoreleaserYmlWithSpecifiedOrAndArch(t *testing.T) {
st := stenciltest.New(t, ".goreleaser.yml.tpl", libraryTmpls...)
st.Args(map[string]interface{}{
"commands": []any{
map[string]any{
"cmd1": map[string]any{
"buildAsset": true,
"os": []any{
"linux",
},
"arch": []any{
"arm64",
},
},
},
},
})
st.Run(stenciltest.RegenerateSnapshots())
}

func TestRenderGolangcilintYaml(t *testing.T) {
Expand Down

0 comments on commit 8a4ea86

Please sign in to comment.