Skip to content

Commit 31c3cd5

Browse files
Merge branch 'main' into elasticsearch-opensearch-authenticator
2 parents 1ba02a8 + 53ac6dd commit 31c3cd5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

internal/storage/v1/elasticsearch/factory_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,15 @@ func TestESStorageFactoryWithConfig(t *testing.T) {
318318

319319
func TestESStorageFactoryWithConfigError(t *testing.T) {
320320
t.Parallel()
321+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
322+
if r.URL.Path == "/" {
323+
w.WriteHeader(http.StatusInternalServerError)
324+
return
325+
}
326+
}))
327+
defer server.Close()
321328
cfg := escfg.Configuration{
322-
Servers: []string{"http://invalid-host-name:65535"},
329+
Servers: []string{server.URL},
323330
DisableHealthCheck: true,
324331
LogLevel: "error",
325332
}

internal/storage/v1/elasticsearch/factoryv1_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func TestArchiveFactory(t *testing.T) {
103103

104104
func TestFactoryInitializeErr(t *testing.T) {
105105
t.Parallel()
106+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
107+
if r.URL.Path == "/" {
108+
w.WriteHeader(http.StatusInternalServerError)
109+
}
110+
}))
111+
defer server.Close()
106112
tests := []struct {
107113
name string
108114
factory *Factory
@@ -116,7 +122,7 @@ func TestFactoryInitializeErr(t *testing.T) {
116122
{
117123
name: "server error",
118124
factory: &Factory{Options: &Options{Config: namespaceConfig{Configuration: escfg.Configuration{
119-
Servers: []string{"http://invalid-host-name:9200"},
125+
Servers: []string{server.URL},
120126
DisableHealthCheck: true,
121127
}}}},
122128
expectedErr: "failed to create Elasticsearch client",

0 commit comments

Comments
 (0)