2023-03-03 14:50:15 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2023-03-03 15:36:45 +02:00
|
|
|
"os"
|
2023-03-03 14:50:15 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHealthcheckSystem(t *testing.T) {
|
|
|
|
cmd := newHealthcheckCmd()
|
|
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml"})
|
|
|
|
require.NoError(t, cmd.cmd.Execute())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHealthcheckConfigThatDoesNotExist(t *testing.T) {
|
|
|
|
cmd := newHealthcheckCmd()
|
|
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/nope.yml"})
|
2023-03-03 15:36:45 +02:00
|
|
|
require.ErrorIs(t, cmd.cmd.Execute(), os.ErrNotExist)
|
2023-03-03 14:50:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestHealthcheckMissingTool(t *testing.T) {
|
|
|
|
cmd := newHealthcheckCmd()
|
|
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/missing_tool.yml"})
|
|
|
|
require.EqualError(t, cmd.cmd.Execute(), "one or more needed tools are not present")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHealthcheckQuier(t *testing.T) {
|
|
|
|
cmd := newHealthcheckCmd()
|
|
|
|
cmd.cmd.SetArgs([]string{"-f", "testdata/good.yml", "--quiet"})
|
|
|
|
require.NoError(t, cmd.cmd.Execute())
|
|
|
|
}
|