1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00

fixed release upload

This commit is contained in:
Carlos Alexandro Becker 2017-07-04 21:28:21 -03:00
parent 183c385e86
commit 1cdfd16d98
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 7 additions and 2 deletions

View File

@ -58,6 +58,7 @@ func upload(ctx *context.Context, client client.Client, releaseID int, artifact
return err return err
} }
defer func() { _ = file.Close() }() defer func() { _ = file.Close() }()
log.WithField("file", file.Name()).Info("uploading") _, name := filepath.Split(path)
return client.Upload(ctx, releaseID, artifact, file) log.WithField("file", file.Name()).WithField("name", name).Info("uploading to release")
return client.Upload(ctx, releaseID, name, file)
} }

View File

@ -46,6 +46,8 @@ func TestRunPipe(t *testing.T) {
assert.NoError(doRun(ctx, client)) assert.NoError(doRun(ctx, client))
assert.True(client.CreatedRelease) assert.True(client.CreatedRelease)
assert.True(client.UploadedFile) assert.True(client.UploadedFile)
assert.Contains("bin.deb", client.UploadedFileNames)
assert.Contains("bin.tar.gz", client.UploadedFileNames)
} }
func TestRunPipeReleaseCreationFailed(t *testing.T) { func TestRunPipeReleaseCreationFailed(t *testing.T) {
@ -141,6 +143,7 @@ type DummyClient struct {
FailToUpload bool FailToUpload bool
CreatedRelease bool CreatedRelease bool
UploadedFile bool UploadedFile bool
UploadedFileNames []string
} }
func (client *DummyClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) { func (client *DummyClient) CreateRelease(ctx *context.Context, body string) (releaseID int, err error) {
@ -160,5 +163,6 @@ func (client *DummyClient) Upload(ctx *context.Context, releaseID int, name stri
return errors.New("upload failed") return errors.New("upload failed")
} }
client.UploadedFile = true client.UploadedFile = true
client.UploadedFileNames = append(client.UploadedFileNames, name)
return return
} }