mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 17:31:00 +02:00
* build(deps): bump golangci/golangci-lint-action from 6 to 7 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * refactor(.github/workflows/ci.yaml): update golangci-lint version to v2.0.2 Signed-off-by: yxxhero <aiopsclub@163.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: yxxhero <aiopsclub@163.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: yxxhero <aiopsclub@163.com>
88 lines
2.2 KiB
Go
88 lines
2.2 KiB
Go
/*
|
|
* MIT License
|
|
*
|
|
* Copyright (c) 2022 urfave/cli maintainers
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
package errors
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var (
|
|
wd, _ = os.Getwd()
|
|
lastExitCode = 0
|
|
fakeOsExiter = func(rc int) {
|
|
lastExitCode = rc
|
|
}
|
|
)
|
|
|
|
func expect(t *testing.T, a any, b any) {
|
|
_, fn, line, _ := runtime.Caller(1)
|
|
fn = strings.ReplaceAll(fn, wd+"/", "")
|
|
|
|
require.Equalf(t, a, b, "(%s:%d) Expected %v (type %v) - Got %v (type %v)", fn, line, b, reflect.TypeOf(b), a, reflect.TypeOf(a))
|
|
}
|
|
|
|
func TestHandleExitCoder_nil(t *testing.T) {
|
|
exitCode := 0
|
|
called := false
|
|
|
|
OsExiter = func(rc int) {
|
|
if !called {
|
|
exitCode = rc
|
|
called = true
|
|
}
|
|
}
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
HandleExitCoder(nil)
|
|
|
|
expect(t, exitCode, 0)
|
|
expect(t, called, false)
|
|
}
|
|
|
|
func TestHandleExitCoder_ExitCoder(t *testing.T) {
|
|
exitCode := 0
|
|
called := false
|
|
|
|
OsExiter = func(rc int) {
|
|
if !called {
|
|
exitCode = rc
|
|
called = true
|
|
}
|
|
}
|
|
|
|
defer func() { OsExiter = fakeOsExiter }()
|
|
|
|
HandleExitCoder(NewExitError("galactic perimeter breach", 9))
|
|
|
|
expect(t, exitCode, 9)
|
|
expect(t, called, true)
|
|
}
|