diff --git a/main.go b/main.go index 1341200..15e93ce 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/main_test.go b/main_test.go index 6650539..50b742f 100644 --- a/main_test.go +++ b/main_test.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/stretchr/testify/assert" "os" "testing" ) @@ -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) +}