Skip to content

Commit

Permalink
Merge pull request #116 from areller/skip-not-uploaded-assets
Browse files Browse the repository at this point in the history
skip not uploaded assets
  • Loading branch information
taylorsilva authored Jun 8, 2022
2 parents 9a3c7fb + d8d46fe commit f963eb9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions in_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
}

for _, asset := range assets {
state := asset.State
if state == nil || *state != "uploaded" {
continue
}

path := filepath.Join(destDir, *asset.Name)

var matchFound bool
Expand Down
17 changes: 15 additions & 2 deletions in_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,20 @@ var _ = Describe("In Command", func() {
}

buildAsset := func(id int64, name string) *github.ReleaseAsset {
state := "uploaded"
return &github.ReleaseAsset{
ID: github.Int64(id),
Name: &name,
ID: github.Int64(id),
Name: &name,
State: &state,
}
}

buildFailedAsset := func(id int64, name string) *github.ReleaseAsset {
state := "starter"
return &github.ReleaseAsset{
ID: github.Int64(id),
Name: &name,
State: &state,
}
}

Expand All @@ -99,6 +110,7 @@ var _ = Describe("In Command", func() {
buildAsset(0, "example.txt"),
buildAsset(1, "example.rtf"),
buildAsset(2, "example.wtf"),
buildFailedAsset(3, "example.doc"),
}, nil)

inRequest.Version = &resource.Version{
Expand Down Expand Up @@ -402,6 +414,7 @@ var _ = Describe("In Command", func() {
Ω(githubClient.DownloadReleaseAssetArgsForCall(0)).Should(Equal(*buildAsset(0, "example.txt")))
Ω(githubClient.DownloadReleaseAssetArgsForCall(1)).Should(Equal(*buildAsset(1, "example.rtf")))
Ω(githubClient.DownloadReleaseAssetArgsForCall(2)).Should(Equal(*buildAsset(2, "example.wtf")))
Ω(githubClient.DownloadReleaseAssetCallCount()).Should(Equal(3))
})
})

Expand Down

0 comments on commit f963eb9

Please sign in to comment.