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
22 changes: 15 additions & 7 deletions graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func TestHandleGraphCommand_Basic(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand Down Expand Up @@ -102,7 +103,7 @@ func TestHandleGraphCommand_Basic(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand All @@ -123,6 +124,7 @@ func TestHandleGraphCommand_Basic(t *testing.T) {
"Total Contributions: 6",
"PRs: 3 total (2 closed, 1 open)",
"Issues: 3 total (2 closed, 1 open)",
"Discussions: 0 total (0 closed, 0 open)",
}

for _, expected := range expectedOutputs {
Expand All @@ -140,6 +142,7 @@ func TestHandleGraphCommand_Basic(t *testing.T) {
func TestHandleGraphCommand_NoPRs(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand Down Expand Up @@ -182,7 +185,7 @@ func TestHandleGraphCommand_NoPRs(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand Down Expand Up @@ -219,6 +222,7 @@ func TestHandleGraphCommand_NoPRs(t *testing.T) {
func TestHandleGraphCommand_NoIssues(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand Down Expand Up @@ -260,7 +264,7 @@ func TestHandleGraphCommand_NoIssues(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand Down Expand Up @@ -297,6 +301,7 @@ func TestHandleGraphCommand_NoIssues(t *testing.T) {
func TestHandleGraphCommand_NoResults(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand All @@ -312,7 +317,7 @@ func TestHandleGraphCommand_NoResults(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand All @@ -328,6 +333,7 @@ func TestHandleGraphCommand_NoResults(t *testing.T) {
func TestHandleGraphCommand_APIError(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand All @@ -337,7 +343,7 @@ func TestHandleGraphCommand_APIError(t *testing.T) {
}

_, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

expectedError := "Error fetching pull requests for graph:"
Expand All @@ -349,6 +355,7 @@ func TestHandleGraphCommand_APIError(t *testing.T) {
func TestHandleGraphCommand_DateHandling(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand Down Expand Up @@ -415,7 +422,7 @@ func TestHandleGraphCommand_DateHandling(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand All @@ -440,6 +447,7 @@ func TestHandleGraphCommand_DateHandling(t *testing.T) {
func TestHandleGraphCommand_WebURL(t *testing.T) {
resetFlags()
mockClient := &MockGitHubClient{}
mockGQLClient := &MockGraphQLClient{}
testLogin := "testuser"
testArgs := []string{"graph", testLogin}

Expand Down Expand Up @@ -491,7 +499,7 @@ func TestHandleGraphCommand_WebURL(t *testing.T) {
}

stdout, stderr := captureOutput(func() {
handleGraphCommand(testArgs, mockClient)
handleGraphCommand(testArgs, mockClient, mockGQLClient)
})

if stderr != "" {
Expand Down
Loading