Skip to content

Commit 9ca9f65

Browse files
committed
Fix staticcheck error: replace meaningless nil check with proper interface test
1 parent 1496393 commit 9ca9f65

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

internal/github/client_test.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,32 @@ func TestMockClient(t *testing.T) {
9797
}
9898
}
9999

100-
// TestClientInterface demonstrates that both Client and MockClient implement ClientInterface
100+
// TestClientInterface demonstrates that MockClient implements ClientInterface
101101
func TestClientInterface(t *testing.T) {
102-
// Verify that both types implement the interface
103-
var client ClientInterface
102+
// Verify that MockClient implements the interface by using it
103+
var client ClientInterface = &MockClient{}
104104

105-
// Test with MockClient
106-
mockClient := &MockClient{}
107-
client = mockClient
108-
if client == nil {
109-
t.Error("MockClient should implement ClientInterface")
105+
// Test that we can call interface methods
106+
issue := &models.Issue{
107+
Title: "Interface Test",
108+
Body: "Testing interface implementation",
109+
}
110+
111+
response, err := client.CreateIssue(issue, "test/repo")
112+
if err != nil {
113+
t.Errorf("Expected no error, got: %v", err)
110114
}
111115

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-
// }
116+
if response.Number != 1 {
117+
t.Errorf("Expected issue number 1, got %d", response.Number)
118+
}
119+
120+
repo, err := client.GetCurrentRepository()
121+
if err != nil {
122+
t.Errorf("Expected no error, got: %v", err)
123+
}
124+
125+
if repo != "mock/repo" {
126+
t.Errorf("Expected repo 'mock/repo', got '%s'", repo)
127+
}
118128
}

0 commit comments

Comments
 (0)