You've already forked go-semantic-release
feat(assets): calculate checksum for all assets and upload it
This commit is contained in:
@@ -13,8 +13,6 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Nightapes/go-semantic-release/pkg/config"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/Nightapes/go-semantic-release/internal/releaser/util"
|
||||
@@ -50,80 +48,6 @@ func TestGetAccessToken(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type testDoubleFiles struct {
|
||||
testFiles []config.Asset
|
||||
valid bool
|
||||
}
|
||||
|
||||
var files = []testDoubleFiles{
|
||||
testDoubleFiles{
|
||||
testFiles: []config.Asset{
|
||||
config.Asset{
|
||||
Name: "file0",
|
||||
Compress: true,
|
||||
},
|
||||
config.Asset{
|
||||
Name: "file1",
|
||||
Compress: true,
|
||||
},
|
||||
},
|
||||
valid: true,
|
||||
},
|
||||
testDoubleFiles{
|
||||
testFiles: []config.Asset{
|
||||
config.Asset{
|
||||
Name: "",
|
||||
Compress: true,
|
||||
},
|
||||
config.Asset{
|
||||
Name: "",
|
||||
Compress: false,
|
||||
},
|
||||
},
|
||||
valid: false,
|
||||
},
|
||||
}
|
||||
|
||||
func TestPrepareAssets(t *testing.T) {
|
||||
for _, testObject := range files {
|
||||
workDir, _ := os.Getwd()
|
||||
filesToDelete := []string{}
|
||||
|
||||
for _, testFile := range testObject.testFiles {
|
||||
|
||||
if testFile.Name != "" {
|
||||
filesToDelete = append(filesToDelete, testFile.Name)
|
||||
|
||||
file, err := os.Create(testFile.Name)
|
||||
if err != nil {
|
||||
fmt.Print(err.Error())
|
||||
}
|
||||
defer file.Close()
|
||||
if testFile.Compress {
|
||||
filesToDelete = append(filesToDelete, testFile.Name+".zip")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
preparedFiles, err := util.PrepareAssets(workDir, testObject.testFiles)
|
||||
|
||||
if err == nil {
|
||||
assert.Equal(t, 2, len(preparedFiles))
|
||||
}
|
||||
|
||||
assert.Equal(t, testObject.valid, err == nil)
|
||||
|
||||
for _, file := range filesToDelete {
|
||||
if err := os.Remove(file); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestShouldRetry(t *testing.T) {
|
||||
assert.True(t, util.ShouldRetry(&http.Response{StatusCode: 429}))
|
||||
assert.False(t, util.ShouldRetry(&http.Response{StatusCode: 200}))
|
||||
|
||||
Reference in New Issue
Block a user