-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pingEndpoint): change build type to 'oss2', use correct version (#…
…21723) Signed-off-by: Jakub Bednar <jakub.bednar@gmail.com>
- Loading branch information
Showing
5 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package legacy | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func TestPingHandler(t *testing.T) { | ||
type wants struct { | ||
statusCode int | ||
version string | ||
build string | ||
} | ||
tests := []struct { | ||
name string | ||
w *httptest.ResponseRecorder | ||
r *http.Request | ||
wants wants | ||
}{ | ||
{ | ||
name: "GET request", | ||
w: httptest.NewRecorder(), | ||
r: httptest.NewRequest(http.MethodGet, "/ping", nil), | ||
wants: wants{ | ||
statusCode: http.StatusNoContent, | ||
version: "2.0.0", | ||
build: "oss2", | ||
}, | ||
}, | ||
{ | ||
name: "HEAD request", | ||
w: httptest.NewRecorder(), | ||
r: httptest.NewRequest(http.MethodHead, "/ping", nil), | ||
wants: wants{ | ||
statusCode: http.StatusNoContent, | ||
version: "2.0.0", | ||
build: "oss2", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
NewPingHandler("2.0.0").pingHandler(tt.w, tt.r) | ||
res := tt.w.Result() | ||
build := res.Header.Get("X-Influxdb-Build") | ||
version := res.Header.Get("X-Influxdb-Version") | ||
|
||
if res.StatusCode != tt.wants.statusCode { | ||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, res.StatusCode, tt.wants.statusCode) | ||
} | ||
if build != tt.wants.build { | ||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, build, tt.wants.build) | ||
} | ||
if version != tt.wants.version { | ||
t.Errorf("%q. PingHandler() = %v, want %v", tt.name, version, tt.wants.version) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters