//go:build integration // +build integration package commands import ( "bytes" "context" "os" "testing" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "tercul/internal/platform/config" "tercul/internal/platform/log" ) // TestBleveMigrateCommand_Help tests that the command help works func TestBleveMigrateCommand_Help(t *testing.T) { cmd := NewBleveMigrateCommand() var buf bytes.Buffer cmd.SetOut(&buf) cmd.SetArgs([]string{"--help"}) err := cmd.Execute() assert.NoError(t, err) assert.Contains(t, buf.String(), "bleve-migrate") assert.Contains(t, buf.String(), "Migrate translations") } // TestBleveMigrateCommand_MissingIndex tests error when index path is missing func TestBleveMigrateCommand_MissingIndex(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") } cmd := NewBleveMigrateCommand() cmd.SetArgs([]string{}) err := cmd.Execute() assert.Error(t, err) assert.Contains(t, err.Error(), "index") } // TestEnrichCommand_Help tests that the enrich command help works func TestEnrichCommand_Help(t *testing.T) { cmd := NewEnrichCommand() var buf bytes.Buffer cmd.SetOut(&buf) cmd.SetArgs([]string{"--help"}) err := cmd.Execute() assert.NoError(t, err) assert.Contains(t, buf.String(), "enrich") } // TestEnrichCommand_MissingArgs tests error when required args are missing func TestEnrichCommand_MissingArgs(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") } cmd := NewEnrichCommand() cmd.SetArgs([]string{}) err := cmd.Execute() assert.Error(t, err) } // TestServeCommand_Help tests that the serve command help works func TestServeCommand_Help(t *testing.T) { cmd := NewServeCommand() var buf bytes.Buffer cmd.SetOut(&buf) cmd.SetArgs([]string{"--help"}) err := cmd.Execute() assert.NoError(t, err) assert.Contains(t, buf.String(), "serve") } // TestWorkerCommand_Help tests that the worker command help works func TestWorkerCommand_Help(t *testing.T) { cmd := NewWorkerCommand() var buf bytes.Buffer cmd.SetOut(&buf) cmd.SetArgs([]string{"--help"}) err := cmd.Execute() assert.NoError(t, err) assert.Contains(t, buf.String(), "worker") } // TestRootCommand tests the root CLI command structure func TestRootCommand(t *testing.T) { // This would test the main CLI, but it's in main.go // We can test that commands are properly registered commands := []func() *cobra.Command{ NewServeCommand, NewWorkerCommand, NewEnrichCommand, NewBleveMigrateCommand, } for _, cmdFn := range commands { cmd := cmdFn() assert.NotNil(t, cmd) assert.NotEmpty(t, cmd.Use) assert.NotEmpty(t, cmd.Short) } }