mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
test: added tests to effective config pipe
Also renamed the pipe from finalconfig to effectiveconfig
This commit is contained in:
parent
06ddedf12a
commit
f3fcb48983
@ -19,8 +19,8 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pipeline/defaults"
|
||||
"github.com/goreleaser/goreleaser/pipeline/dist"
|
||||
"github.com/goreleaser/goreleaser/pipeline/docker"
|
||||
"github.com/goreleaser/goreleaser/pipeline/effectiveconfig"
|
||||
"github.com/goreleaser/goreleaser/pipeline/env"
|
||||
"github.com/goreleaser/goreleaser/pipeline/finalconfig"
|
||||
"github.com/goreleaser/goreleaser/pipeline/fpm"
|
||||
"github.com/goreleaser/goreleaser/pipeline/git"
|
||||
"github.com/goreleaser/goreleaser/pipeline/release"
|
||||
@ -38,20 +38,20 @@ func init() {
|
||||
}
|
||||
|
||||
var pipes = []pipeline.Piper{
|
||||
defaults.Pipe{}, // load default configs
|
||||
dist.Pipe{}, // ensure ./dist is clean
|
||||
finalconfig.Pipe{}, // writes the actual config (with defaults et al set) to dist
|
||||
git.Pipe{}, // get and validate git repo state
|
||||
changelog.Pipe{}, // builds the release changelog
|
||||
env.Pipe{}, // load and validate environment variables
|
||||
build.Pipe{}, // build
|
||||
archive.Pipe{}, // archive (tar.gz, zip, etc)
|
||||
fpm.Pipe{}, // archive via fpm (deb, rpm, etc)
|
||||
snapcraft.Pipe{}, // archive via snapcraft (snap)
|
||||
checksums.Pipe{}, // checksums of the files
|
||||
docker.Pipe{}, // create and push docker images
|
||||
release.Pipe{}, // release to github
|
||||
brew.Pipe{}, // push to brew tap
|
||||
defaults.Pipe{}, // load default configs
|
||||
dist.Pipe{}, // ensure ./dist is clean
|
||||
effectiveconfig.Pipe{}, // writes the actual config (with defaults et al set) to dist
|
||||
git.Pipe{}, // get and validate git repo state
|
||||
changelog.Pipe{}, // builds the release changelog
|
||||
env.Pipe{}, // load and validate environment variables
|
||||
build.Pipe{}, // build
|
||||
archive.Pipe{}, // archive (tar.gz, zip, etc)
|
||||
fpm.Pipe{}, // archive via fpm (deb, rpm, etc)
|
||||
snapcraft.Pipe{}, // archive via snapcraft (snap)
|
||||
checksums.Pipe{}, // checksums of the files
|
||||
docker.Pipe{}, // create and push docker images
|
||||
release.Pipe{}, // release to github
|
||||
brew.Pipe{}, // push to brew tap
|
||||
}
|
||||
|
||||
// Flags interface represents an extractor of cli flags
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pipeline/snapshot"
|
||||
)
|
||||
|
||||
// Pipe for brew deployment
|
||||
// Pipe that sets the defaults
|
||||
type Pipe struct{}
|
||||
|
||||
func (Pipe) String() string {
|
||||
@ -50,4 +50,3 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package finalconfig
|
||||
package effectiveconfig
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
@ -9,19 +9,21 @@ import (
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Pipe that writes the effective config file to dist
|
||||
type Pipe struct {
|
||||
}
|
||||
|
||||
func (Pipe) String() string {
|
||||
return "writing the final config file to dist folder"
|
||||
return "writing effective config file"
|
||||
}
|
||||
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
var path = filepath.Join(ctx.Config.Dist, "config.yaml")
|
||||
bts, err := yaml.Marshal(ctx.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.WithField("path", path).Info("writting")
|
||||
log.WithField("config", path).Info("writting")
|
||||
return ioutil.WriteFile(path, bts, 0644)
|
||||
}
|
33
pipeline/effectiveconfig/config_test.go
Normal file
33
pipeline/effectiveconfig/config_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package effectiveconfig
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPipeDescription(t *testing.T) {
|
||||
assert.NotEmpty(t, Pipe{}.String())
|
||||
}
|
||||
|
||||
func Test(t *testing.T) {
|
||||
folder, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
dist := filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
var ctx = context.New(
|
||||
config.Project{
|
||||
Dist: dist,
|
||||
},
|
||||
)
|
||||
assert.NoError(t, Pipe{}.Run(ctx))
|
||||
bts, err := ioutil.ReadFile(filepath.Join(dist, "config.yaml"))
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, string(bts))
|
||||
}
|
Loading…
Reference in New Issue
Block a user