Fix tests, don't run the queue if it's a dry run push

This commit is contained in:
rubyist 2015-04-24 11:56:22 -04:00
parent a1ed0f2dcc
commit d9c36fa872
3 changed files with 13 additions and 11 deletions

@ -126,13 +126,15 @@ func pushCommand(cmd *cobra.Command, args []string) {
uploadQueue.Upload(u)
}
uploadQueue.Process()
if errs := uploadQueue.Errors(); len(errs) > 0 {
// TODO: how to display multiple errors
if Debugging || errs[0].Panic {
Panic(errs[0].Err, errs[0].Error())
} else {
Exit(errs[0].Error())
if !dryRun {
uploadQueue.Process()
if errs := uploadQueue.Errors(); len(errs) > 0 {
// TODO: how to display multiple errors
if Debugging || errs[0].Panic {
Panic(errs[0].Err, errs[0].Error())
} else {
Exit(errs[0].Error())
}
}
}
}

@ -106,7 +106,7 @@ func TestExistingUpload(t *testing.T) {
// stores callbacks
calls := make([][]int64, 0, 5)
cb := func(total int64, written int64) error {
cb := func(total int64, written int64, current int) error {
calls = append(calls, []int64{total, written})
return nil
}
@ -394,7 +394,7 @@ func TestSuccessfulUploadWithVerify(t *testing.T) {
// stores callbacks
calls := make([][]int64, 0, 5)
cb := func(total int64, written int64) error {
cb := func(total int64, written int64, current int) error {
calls = append(calls, []int64{total, written})
return nil
}

@ -14,7 +14,7 @@ func TestWriterWithCallback(t *testing.T) {
reader := &CallbackReader{
TotalSize: 5,
Reader: bytes.NewBufferString("BOOYA"),
C: func(total int64, read int64) error {
C: func(total int64, read int64, current int) error {
called += 1
calledRead = append(calledRead, read)
assert.Equal(t, 5, int(total))
@ -43,7 +43,7 @@ func TestCopyWithCallback(t *testing.T) {
called := 0
calledWritten := make([]int64, 0, 2)
n, err := CopyWithCallback(ioutil.Discard, buf, 5, func(total int64, written int64) error {
n, err := CopyWithCallback(ioutil.Discard, buf, 5, func(total int64, written int64, current int) error {
called += 1
calledWritten = append(calledWritten, written)
assert.Equal(t, 5, int(total))