mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
fix: remove unuseful unit test
This commit is contained in:
parent
fe1d9de6f1
commit
d5498dde73
@ -1,14 +1,12 @@
|
|||||||
package client_test
|
package client_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http/httptest"
|
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/foomo/contentserver/client"
|
"github.com/foomo/contentserver/client"
|
||||||
"github.com/foomo/contentserver/content"
|
"github.com/foomo/contentserver/content"
|
||||||
"github.com/foomo/contentserver/pkg/handler"
|
|
||||||
"github.com/foomo/contentserver/pkg/repo"
|
"github.com/foomo/contentserver/pkg/repo"
|
||||||
"github.com/foomo/contentserver/pkg/repo/mock"
|
"github.com/foomo/contentserver/pkg/repo/mock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -165,53 +163,6 @@ func initRepo(tb testing.TB, l *zap.Logger) *repo.Repo {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRepo_UpdateFails(t *testing.T) {
|
|
||||||
t.Helper()
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
l := zaptest.NewLogger(t)
|
|
||||||
|
|
||||||
// Step 1: create a working repo and let it populate history
|
|
||||||
testRepoServer, varDir := mock.GetMockData(t)
|
|
||||||
historyDir := varDir
|
|
||||||
|
|
||||||
workingRepo := repo.New(l,
|
|
||||||
testRepoServer.URL+"/repo-two-dimensions.json",
|
|
||||||
repo.NewHistory(l, repo.HistoryWithHistoryDir(historyDir)),
|
|
||||||
)
|
|
||||||
go func() {
|
|
||||||
if err := workingRepo.Start(t.Context()); err != nil {
|
|
||||||
t.Errorf("workingRepo.Start failed: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Give it time to persist JSON
|
|
||||||
time.Sleep(300 * time.Millisecond)
|
|
||||||
|
|
||||||
// Step 2: create a new repo with a broken upstream, but reusing the same history
|
|
||||||
brokenRepo := repo.New(l,
|
|
||||||
"http://localhost:9999/this-will-fail-non-existent.json", // force failure
|
|
||||||
repo.NewHistory(l, repo.HistoryWithHistoryDir(historyDir)),
|
|
||||||
)
|
|
||||||
go func() {
|
|
||||||
if err := brokenRepo.Start(t.Context()); err != nil {
|
|
||||||
t.Errorf("brokenRepo.Start failed: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Step 3: serve it
|
|
||||||
server := httptest.NewServer(handler.NewHTTP(l, brokenRepo))
|
|
||||||
defer server.Close()
|
|
||||||
|
|
||||||
client, err := client.NewHTTPClient(server.URL + pathContentserver)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Step 4: trigger GetRepo, which will log warning and fall back to existing file
|
|
||||||
result, err := client.GetRepo(t.Context())
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.NotEmpty(t, result, "expected fallback repo content from WriteRepoBytes")
|
|
||||||
}
|
|
||||||
|
|
||||||
// func dump(t *testing.T, v interface{}) {
|
// func dump(t *testing.T, v interface{}) {
|
||||||
// t.Helper()
|
// t.Helper()
|
||||||
// jsonBytes, err := json.MarshalIndent(v, "", " ")
|
// jsonBytes, err := json.MarshalIndent(v, "", " ")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user