mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package outputs_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ClickHouse/ClickHouse/programs/diagnostics/internal/outputs"
|
|
"github.com/ClickHouse/ClickHouse/programs/diagnostics/internal/outputs/file"
|
|
_ "github.com/ClickHouse/ClickHouse/programs/diagnostics/internal/outputs/terminal"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetOutputNames(t *testing.T) {
|
|
t.Run("can get all output names", func(t *testing.T) {
|
|
outputNames := outputs.GetOutputNames()
|
|
require.ElementsMatch(t, []string{"simple", "report"}, outputNames)
|
|
})
|
|
|
|
}
|
|
|
|
func TestGetOutputByName(t *testing.T) {
|
|
|
|
t.Run("can get output by name", func(t *testing.T) {
|
|
output, err := outputs.GetOutputByName("simple")
|
|
require.Nil(t, err)
|
|
require.Equal(t, file.SimpleOutput{}, output)
|
|
})
|
|
|
|
t.Run("fails on non existing output", func(t *testing.T) {
|
|
output, err := outputs.GetOutputByName("random")
|
|
require.NotNil(t, err)
|
|
require.Equal(t, "random is not a valid output name", err.Error())
|
|
require.Nil(t, output)
|
|
})
|
|
}
|
|
|
|
func TestBuildConfigurationOptions(t *testing.T) {
|
|
|
|
t.Run("can get all output configurations", func(t *testing.T) {
|
|
outputs, err := outputs.BuildConfigurationOptions()
|
|
require.Nil(t, err)
|
|
require.Len(t, outputs, 2)
|
|
require.Contains(t, outputs, "simple")
|
|
require.Contains(t, outputs, "report")
|
|
})
|
|
}
|