Skip to content

Commit 134cd62

Browse files
committed
Ensure -config-init is valid
1 parent cc29394 commit 134cd62

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

integration/cli_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package integration
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"path/filepath"
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
func TestCLIConfigInitGeneratesValidConfig(t *testing.T) {
14+
tmpDir := t.TempDir()
15+
configPath := filepath.Join(tmpDir, "generated-config.json")
16+
17+
t.Run("generate and validate config", func(t *testing.T) {
18+
// Step 1: Generate config with -config-init
19+
cmd := exec.Command("../cmd/mcp-front/mcp-front", "-config-init", configPath)
20+
output, err := cmd.CombinedOutput()
21+
22+
t.Logf("config-init output: %s", output)
23+
24+
require.NoError(t, err, "config-init should succeed")
25+
assert.Contains(t, string(output), "Generated default config at:", "should report generation")
26+
27+
// Verify file was created
28+
fi, err := os.Stat(configPath)
29+
require.NoError(t, err, "config file should exist")
30+
require.Greater(t, fi.Size(), int64(0), "config file should not be empty")
31+
32+
// Step 2: Validate the generated config
33+
cmd = exec.Command("../cmd/mcp-front/mcp-front", "-config", configPath, "-validate")
34+
output, err = cmd.CombinedOutput()
35+
36+
t.Logf("validate output: %s", output)
37+
38+
// The generated config should be valid
39+
require.NoError(t, err, "validate should succeed for config-init generated file")
40+
assert.Contains(t, string(output), "Result: PASS", "validation should pass")
41+
})
42+
}

0 commit comments

Comments
 (0)