Skip to content

Commit

Permalink
Validate handler is called
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-xie committed Mar 6, 2024
1 parent 3fffd59 commit 886a0fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/elasticsearch/client/v6/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func TestNewV6Client(t *testing.T) {
}

func TestCreateIndex(t *testing.T) {
var handlerCalled bool
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handlerCalled = true
if r.URL.Path == "/testIndex" && r.Method == "PUT" {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"acknowledged": true}`))
Expand All @@ -82,6 +84,7 @@ func TestCreateIndex(t *testing.T) {
elasticV6, testServer := getMockClient(t, handler)
defer testServer.Close()
err := elasticV6.CreateIndex(context.Background(), "testIndex")
assert.True(t, handlerCalled, "Expected handler to be called")
assert.NoError(t, err)
}

Expand Down

0 comments on commit 886a0fd

Please sign in to comment.