mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Prevent test-docker and test-docker-online from running the same 36 offline integration tests. Each offline test file now has `//go:build !online` so the two sets are mutually exclusive: - default (no tag): 36 offline tests only - -tags online: online tests only
104 lines
3.0 KiB
Go
104 lines
3.0 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestInitProject_Fresh_CreatesStructure(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
projectRoot := filepath.Join(sb.Root, "project")
|
|
os.MkdirAll(projectRoot, 0755)
|
|
|
|
result := sb.RunCLIInDir(projectRoot, "init", "-p", "--targets", "claude-code,cursor")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "Initialized successfully")
|
|
|
|
// Verify structure
|
|
if !sb.FileExists(filepath.Join(projectRoot, ".skillshare", "config.yaml")) {
|
|
t.Error(".skillshare/config.yaml should exist")
|
|
}
|
|
if !sb.FileExists(filepath.Join(projectRoot, ".skillshare", "skills")) {
|
|
t.Error(".skillshare/skills/ should exist")
|
|
}
|
|
if !sb.FileExists(filepath.Join(projectRoot, ".skillshare", ".gitignore")) {
|
|
t.Error(".skillshare/.gitignore should exist")
|
|
}
|
|
// Target dirs created
|
|
if !sb.FileExists(filepath.Join(projectRoot, ".claude", "skills")) {
|
|
t.Error(".claude/skills/ should exist")
|
|
}
|
|
if !sb.FileExists(filepath.Join(projectRoot, ".cursor", "skills")) {
|
|
t.Error(".cursor/skills/ should exist")
|
|
}
|
|
}
|
|
|
|
func TestInitProject_AlreadyInitialized_Error(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
projectRoot := sb.SetupProjectDir("claude-code")
|
|
result := sb.RunCLIInDir(projectRoot, "init", "-p", "--targets", "claude-code")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "already initialized")
|
|
}
|
|
|
|
func TestInitProject_DryRun_NoFiles(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
projectRoot := filepath.Join(sb.Root, "project")
|
|
os.MkdirAll(projectRoot, 0755)
|
|
|
|
result := sb.RunCLIInDir(projectRoot, "init", "-p", "--targets", "claude-code", "--dry-run")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "Dry run")
|
|
|
|
if sb.FileExists(filepath.Join(projectRoot, ".skillshare", "config.yaml")) {
|
|
t.Error("dry-run should not create config")
|
|
}
|
|
}
|
|
|
|
func TestInitProject_ConfigContainsTargets(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
projectRoot := filepath.Join(sb.Root, "project")
|
|
os.MkdirAll(projectRoot, 0755)
|
|
|
|
result := sb.RunCLIInDir(projectRoot, "init", "-p", "--targets", "claude-code,cursor")
|
|
result.AssertSuccess(t)
|
|
|
|
cfg := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", "config.yaml"))
|
|
if !strings.Contains(cfg, "claude-code") {
|
|
t.Error("config should contain claude-code target")
|
|
}
|
|
if !strings.Contains(cfg, "cursor") {
|
|
t.Error("config should contain cursor target")
|
|
}
|
|
}
|
|
|
|
func TestInitProject_GitignoreIncludesLogsDirectory(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
projectRoot := filepath.Join(sb.Root, "project")
|
|
os.MkdirAll(projectRoot, 0755)
|
|
|
|
result := sb.RunCLIInDir(projectRoot, "init", "-p", "--targets", "claude-code")
|
|
result.AssertSuccess(t)
|
|
|
|
gitignore := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"))
|
|
if !strings.Contains(gitignore, "logs/") {
|
|
t.Errorf("project .gitignore should include logs/, got:\n%s", gitignore)
|
|
}
|
|
}
|