@@ -6,6 +6,32 @@ import (
66 "github.com/ntsk/gh-issue-bulk-create/pkg/models"
77)
88
9+ // MockClient provides a mock GitHub client for testing
10+ type MockClient struct {
11+ CreateIssueFunc func (issue * models.Issue , repo string ) (* models.IssueResponse , error )
12+ GetCurrentRepoFunc func () (string , error )
13+ CreatedIssues []* models.Issue
14+ GetCurrentRepoCounter int
15+ }
16+
17+ // CreateIssue implements the ClientInterface for testing
18+ func (m * MockClient ) CreateIssue (issue * models.Issue , repo string ) (* models.IssueResponse , error ) {
19+ m .CreatedIssues = append (m .CreatedIssues , issue )
20+ if m .CreateIssueFunc != nil {
21+ return m .CreateIssueFunc (issue , repo )
22+ }
23+ return & models.IssueResponse {Number : 1 , URL : "https://github.com/mock/repo/issues/1" }, nil
24+ }
25+
26+ // GetCurrentRepository implements the ClientInterface for testing
27+ func (m * MockClient ) GetCurrentRepository () (string , error ) {
28+ m .GetCurrentRepoCounter ++
29+ if m .GetCurrentRepoFunc != nil {
30+ return m .GetCurrentRepoFunc ()
31+ }
32+ return "mock/repo" , nil
33+ }
34+
935func TestMockClient (t * testing.T ) {
1036 // Create mock client
1137 mockClient := & MockClient {}
@@ -70,3 +96,23 @@ func TestMockClient(t *testing.T) {
7096 t .Errorf ("Expected custom repo 'custom/repo', got '%s'" , repo )
7197 }
7298}
99+
100+ // TestClientInterface demonstrates that both Client and MockClient implement ClientInterface
101+ func TestClientInterface (t * testing.T ) {
102+ // Verify that both types implement the interface
103+ var client ClientInterface
104+
105+ // Test with MockClient
106+ mockClient := & MockClient {}
107+ client = mockClient
108+ if client == nil {
109+ t .Error ("MockClient should implement ClientInterface" )
110+ }
111+
112+ // Test with real Client (this would fail without proper initialization in tests)
113+ // realClient := &Client{}
114+ // client = realClient
115+ // if client == nil {
116+ // t.Error("Client should implement ClientInterface")
117+ // }
118+ }
0 commit comments