mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 04:01:34 +00:00
Some checks failed
- Updated database models and repositories to replace uint IDs with UUIDs. - Modified test fixtures to generate and use UUIDs for authors, translations, users, and works. - Adjusted mock implementations to align with the new UUID structure. - Ensured all relevant functions and methods are updated to handle UUIDs correctly. - Added necessary imports for UUID handling in various files.
117 lines
2.7 KiB
Go
117 lines
2.7 KiB
Go
//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)
|
|
}
|
|
}
|