1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-05-31 23:19:45 +02:00

fixed tests and linters

This commit is contained in:
Carlos Alexandro Becker 2017-01-11 14:08:29 -02:00
parent ee915f2316
commit b4b69ddb25
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 8 additions and 5 deletions

View File

@ -67,7 +67,7 @@ func (Pipe) Run(config config.ProjectConfig) error {
if err != nil {
return err
}
sha, err := sha(client, owner, repo, name, out)
sha, err := formulaeSHA(client, owner, repo, name, out)
if err != nil {
return err
}
@ -79,13 +79,13 @@ func (Pipe) Run(config config.ProjectConfig) error {
},
Content: out.Bytes(),
Message: github.String(config.BinaryName + " version " + config.Git.CurrentTag),
SHA256: sha,
SHA: sha,
},
)
return err
}
func sha(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
func formulaeSHA(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
file, _, _, err := client.Repositories.GetContents(
owner, repo, name, &github.RepositoryContentGetOptions{},
)
@ -144,6 +144,7 @@ func dataFor(config config.ProjectConfig, client *github.Client) (result templat
BinaryName: config.BinaryName,
Caveats: config.Brew.Caveats,
Format: config.Archive.Format,
SHA256: sum,
}, err
}

View File

@ -25,6 +25,7 @@ var defaultTemplateData = templateData{
Name: "Test",
Repo: "caarlos0/test",
Tag: "v0.1.3",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
Format: "tar.gz",
}
@ -33,9 +34,10 @@ func assertDefaultTemplateData(t *testing.T, formulae string) {
assert.Contains(formulae, "class Test < Formula")
assert.Contains(formulae, "homepage \"https://google.com\"")
assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"")
assert.Contains(formulae, "head \"https://github.com/caarlos0/test.git\"")
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
assert.Contains(formulae, "version \"v0.1.3\"")
assert.Contains(formulae, "bin.install \"test\"")
}
func TestFullFormulae(t *testing.T) {

View File

@ -12,7 +12,7 @@ func For(path string) (result string, err error) {
if err != nil {
return
}
defer file.Close()
defer func() { _ = file.Close() }()
hash := sha256.New()
_, err = io.Copy(hash, file)