mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Refactor older tests to use testify (#33140)
Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
This commit is contained in:
		| @@ -15,6 +15,7 @@ import ( | ||||
|  | ||||
| 	"github.com/meilisearch/meilisearch-go" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func TestMeilisearchIndexer(t *testing.T) { | ||||
| @@ -32,20 +33,10 @@ func TestMeilisearchIndexer(t *testing.T) { | ||||
| 		key = os.Getenv("TEST_MEILISEARCH_KEY") | ||||
| 	} | ||||
|  | ||||
| 	ok := false | ||||
| 	for i := 0; i < 60; i++ { | ||||
| 	require.Eventually(t, func() bool { | ||||
| 		resp, err := http.Get(url) | ||||
| 		if err == nil && resp.StatusCode == http.StatusOK { | ||||
| 			ok = true | ||||
| 			break | ||||
| 		} | ||||
| 		t.Logf("Waiting for meilisearch to be up: %v", err) | ||||
| 		time.Sleep(time.Second) | ||||
| 	} | ||||
| 	if !ok { | ||||
| 		t.Fatalf("Failed to wait for meilisearch to be up") | ||||
| 		return | ||||
| 	} | ||||
| 		return err == nil && resp.StatusCode == http.StatusOK | ||||
| 	}, time.Minute, time.Second, "Expected meilisearch to be up") | ||||
|  | ||||
| 	indexer := NewIndexer(url, key, fmt.Sprintf("test_meilisearch_indexer_%d", time.Now().Unix())) | ||||
| 	defer indexer.Close() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user