Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cmd/integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"bytes"
"strings"
"testing"
)

func TestListCommand_IncludesMain(t *testing.T) {
// Skip this test for now as it's outputting to stdout directly
t.Skip("List command outputs directly to stdout, needs refactoring to test properly")
}

func TestSwitchCommand_HandlesMain(t *testing.T) {
// Create a buffer to capture output
var buf bytes.Buffer

// Create command with "main" argument
cmd := newSwitchCmd()
cmd.SetOut(&buf)
cmd.SetErr(&buf)
cmd.SetArgs([]string{"main"})

// Execute command
err := cmd.Execute()
if err != nil {
// It's OK if the command fails due to not finding the session in test environment
// We're mainly testing that it doesn't crash
return
}

// Check output contains cd command
output := buf.String()
if strings.Contains(output, "cd ") {
// Success - it tried to switch
return
}
}
Loading
Loading