Skip to content

Commit

Permalink
Add returning of error in case if artifact is not found in github rel…
Browse files Browse the repository at this point in the history
…ease info (#110)
  • Loading branch information
denis256 authored Aug 3, 2022
1 parent 7173349 commit ebabfd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func downloadReleaseAssets(logger *logrus.Logger, assetRegex string, destPath st

release, releaseInfoErr := GetGitHubReleaseInfo(githubRepo, tag)
if releaseInfoErr != nil {
return nil, err
return nil, releaseInfoErr
}

assets, err := findAssetsInRelease(assetRegex, release)
Expand Down
18 changes: 18 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
Expand Down Expand Up @@ -95,3 +96,20 @@ func TestInvalidReleaseAssetsRegex(t *testing.T) {
t.Fatalf("Expected error for invalid regex")
}
}

func TestInvalidReleaseAssetTag(t *testing.T) {
tmpDir := mkTempDir(t)
logger := GetProjectLogger()
testInst := GitHubInstance{
BaseUrl: "github.com",
ApiUrl: "api.github.com",
}

githubRepo, err := ParseUrlIntoGitHubRepo(SAMPLE_RELEASE_ASSET_GITHUB_REPO_URL, "", testInst)
if err != nil {
t.Fatalf("Failed to parse sample release asset GitHub URL into Fetch GitHubRepo struct: %s", err)
}

_, fetchErr := downloadReleaseAssets(logger, SAMPLE_RELEASE_ASSET_REGEX, tmpDir, githubRepo, "6.6.6", false)
assert.Error(t, fetchErr)
}

0 comments on commit ebabfd6

Please sign in to comment.