forgejo/modules/indexer/issues/elasticsearch/elasticsearch_test.go
Earl Warren 563d8f1564 chore(ci): skip tests if TEST_{MINIO_ENDPOINT,ELASTICSEARCH_URL} is not set (#8166)
This allows the daily tests to work instead of failing because elasticsearch & minio are not present.

* [Minio](https://codeberg.org/forgejo-integration/forgejo/actions/runs/10172#jobstep-5-353)
* [Elasticsearch](https://codeberg.org/forgejo-integration/forgejo/actions/runs/10172#jobstep-5-272)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8166
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-06-12 21:13:52 +02:00

34 lines
783 B
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package elasticsearch
import (
"fmt"
"net/http"
"os"
"testing"
"time"
"forgejo.org/modules/indexer/issues/internal/tests"
"github.com/stretchr/testify/require"
)
func TestElasticsearchIndexer(t *testing.T) {
url := os.Getenv("TEST_ELASTICSEARCH_URL")
if url == "" {
t.Skip("TEST_ELASTICSEARCH_URL not set")
return
}
require.Eventually(t, func() bool {
resp, err := http.Get(url)
return err == nil && resp.StatusCode == http.StatusOK
}, time.Minute, time.Microsecond*100, "Failed to wait for elasticsearch to be up")
indexer := NewIndexer(url, fmt.Sprintf("test_elasticsearch_indexer_%d", time.Now().Unix()))
defer indexer.Close()
tests.TestIndexer(t, indexer)
}