mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 08:00:52 +00:00
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>
34 lines
783 B
Go
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)
|
|
}
|