github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/updater/util/error_test.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package util
     5  
     6  import (
     7  	"errors"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  func TestCombineErrors(t *testing.T) {
    14  	assert.Equal(t, nil, CombineErrors(nil))
    15  	assert.Equal(t, nil, CombineErrors(nil, nil))
    16  	assert.Equal(t, "1 error", CombineErrors(errors.New("1 error"), nil).Error())
    17  	assert.Equal(t, "1 error", CombineErrors(nil, errors.New("1 error")).Error())
    18  	assert.Equal(t, "There were multiple errors: 1 error; 2 error", CombineErrors(nil, errors.New("1 error"), errors.New("2 error")).Error())
    19  	assert.Equal(t, "There were multiple errors: 1 error; 2 error", CombineErrors(nil, errors.New("1 error"), errors.New("2 error"), nil).Error())
    20  	assert.Equal(t, "There were multiple errors: 1 error; 2 error", CombineErrors(nil, errors.New("1 error"), nil, errors.New("2 error"), nil).Error())
    21  }