@@ -11,26 +11,6 @@ import (
1111 "github.com/nlink-jp/splunk-cli/internal/config"
1212)
1313
14- func newTestClient (t * testing.T , handler http.Handler ) * Client {
15- t .Helper ()
16- srv := httptest .NewTLSServer (handler )
17- t .Cleanup (srv .Close )
18-
19- cfg := & config.Config {
20- Host : srv .URL ,
21- Token : "testtoken" ,
22- Insecure : true ,
23- }
24- c , err := New (cfg , true )
25- if err != nil {
26- t .Fatalf ("New: %v" , err )
27- }
28- // Use the test server's TLS client to handle self-signed cert.
29- c .http = srv .Client ()
30- // Re-add token setup by wrapping the transport.
31- return c
32- }
33-
3414func TestStartSearch (t * testing.T ) {
3515 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
3616 if r .Method != http .MethodPost {
@@ -40,7 +20,7 @@ func TestStartSearch(t *testing.T) {
4020 t .Errorf ("unexpected path: %s" , r .URL .Path )
4121 }
4222 w .WriteHeader (http .StatusCreated )
43- json .NewEncoder (w ).Encode (map [string ]string {"sid" : "test_sid_123" })
23+ _ = json .NewEncoder (w ).Encode (map [string ]string {"sid" : "test_sid_123" })
4424 })
4525
4626 srv := httptest .NewServer (handler )
@@ -64,10 +44,10 @@ func TestStartSearch(t *testing.T) {
6444func TestStartSearch_PipePrefix (t * testing.T ) {
6545 var gotSearch string
6646 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
67- r .ParseForm ()
47+ _ = r .ParseForm ()
6848 gotSearch = r .FormValue ("search" )
6949 w .WriteHeader (http .StatusCreated )
70- json .NewEncoder (w ).Encode (map [string ]string {"sid" : "sid1" })
50+ _ = json .NewEncoder (w ).Encode (map [string ]string {"sid" : "sid1" })
7151 })
7252
7353 srv := httptest .NewServer (handler )
@@ -77,13 +57,13 @@ func TestStartSearch_PipePrefix(t *testing.T) {
7757 c , _ := New (cfg , true )
7858
7959 // SPL starting with | should NOT get "search " prefix.
80- c .StartSearch (context .Background (), "| stats count" , "" , "" )
60+ _ , _ = c .StartSearch (context .Background (), "| stats count" , "" , "" )
8161 if gotSearch != "| stats count" {
8262 t .Errorf ("pipe SPL should not get prefix, got: %q" , gotSearch )
8363 }
8464
8565 // Normal SPL should get "search " prefix.
86- c .StartSearch (context .Background (), "index=main" , "" , "" )
66+ _ , _ = c .StartSearch (context .Background (), "index=main" , "" , "" )
8767 if gotSearch != "search index=main" {
8868 t .Errorf ("normal SPL should get prefix, got: %q" , gotSearch )
8969 }
@@ -92,7 +72,7 @@ func TestStartSearch_PipePrefix(t *testing.T) {
9272func TestGetJobStatus (t * testing.T ) {
9373 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
9474 w .Header ().Set ("Content-Type" , "application/json" )
95- json .NewEncoder (w ).Encode (map [string ]any {
75+ _ = json .NewEncoder (w ).Encode (map [string ]any {
9676 "entry" : []map [string ]any {
9777 {"content" : map [string ]any {
9878 "isDone" : true ,
@@ -127,7 +107,7 @@ func TestGetJobStatus(t *testing.T) {
127107
128108func TestGetJobStatus_NotFound (t * testing.T ) {
129109 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
130- json .NewEncoder (w ).Encode (map [string ]any {"entry" : []any {}})
110+ _ = json .NewEncoder (w ).Encode (map [string ]any {"entry" : []any {}})
131111 })
132112
133113 srv := httptest .NewServer (handler )
@@ -145,7 +125,7 @@ func TestGetJobStatus_NotFound(t *testing.T) {
145125func TestGetJobStatus_APIError (t * testing.T ) {
146126 handler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
147127 w .WriteHeader (http .StatusUnauthorized )
148- w .Write ([]byte ("Unauthorized" ))
128+ _ , _ = w .Write ([]byte ("Unauthorized" ))
149129 })
150130
151131 srv := httptest .NewServer (handler )
@@ -168,7 +148,7 @@ func TestCancelSearch(t *testing.T) {
168148 if ! strings .Contains (r .URL .Path , "control" ) {
169149 t .Errorf ("unexpected path: %s" , r .URL .Path )
170150 }
171- r .ParseForm ()
151+ _ = r .ParseForm ()
172152 if r .FormValue ("action" ) != "cancel" {
173153 t .Errorf ("expected action=cancel, got %q" , r .FormValue ("action" ))
174154 }
0 commit comments