Expand test coverage across server, agent, and web; fix bugs found during audit.
Adds hundreds of unit/integration/e2e tests, fixes WS bcrypt auth, config merge, fleet analytics, agent schedule/log tail, and documents stale PROBLEMS items. Updates PROBLEMS.md, README, and test scripts; ignores local spread-kits and coverage dirs.
This commit is contained in:
@@ -43,15 +43,15 @@ func setMockHTTPTransport(t *testing.T, fn roundTripFunc) {
|
||||
t.Cleanup(func() { http.DefaultTransport = orig })
|
||||
}
|
||||
|
||||
func resetXMRPriceCache(t *testing.T) {
|
||||
func resetXMRPriceCache(t *testing.T, fh *FleetHandler) {
|
||||
t.Helper()
|
||||
xmrPriceMu.Lock()
|
||||
xmrPriceCache = nil
|
||||
xmrPriceMu.Unlock()
|
||||
fh.xmrPriceMu.Lock()
|
||||
fh.xmrPriceCache = nil
|
||||
fh.xmrPriceMu.Unlock()
|
||||
t.Cleanup(func() {
|
||||
xmrPriceMu.Lock()
|
||||
xmrPriceCache = nil
|
||||
xmrPriceMu.Unlock()
|
||||
fh.xmrPriceMu.Lock()
|
||||
fh.xmrPriceCache = nil
|
||||
fh.xmrPriceMu.Unlock()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -270,13 +270,12 @@ func TestFleetGetAIActivityWithEntries(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFleetGetXMRPriceCacheHit(t *testing.T) {
|
||||
resetXMRPriceCache(t)
|
||||
fetchedAt := time.Now().Add(-2 * time.Minute)
|
||||
xmrPriceMu.Lock()
|
||||
xmrPriceCache = &xmrPriceEntry{USD: 165.5, fetchedAt: fetchedAt}
|
||||
xmrPriceMu.Unlock()
|
||||
|
||||
fh, _, _, _ := newTestFleetHandler(t)
|
||||
resetXMRPriceCache(t, fh)
|
||||
fetchedAt := time.Now().Add(-2 * time.Minute)
|
||||
fh.xmrPriceMu.Lock()
|
||||
fh.xmrPriceCache = &xmrPriceEntry{USD: 165.5, fetchedAt: fetchedAt}
|
||||
fh.xmrPriceMu.Unlock()
|
||||
rec := httptest.NewRecorder()
|
||||
fh.GetXMRPrice(rec, httptest.NewRequest(http.MethodGet, "/market/xmr", nil))
|
||||
if rec.Code != http.StatusOK {
|
||||
@@ -292,7 +291,6 @@ func TestFleetGetXMRPriceCacheHit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFleetGetXMRPriceFetchSuccess(t *testing.T) {
|
||||
resetXMRPriceCache(t)
|
||||
setMockHTTPTransport(t, func(req *http.Request) (*http.Response, error) {
|
||||
if !strings.Contains(req.URL.Host, "coingecko.com") {
|
||||
t.Fatalf("unexpected host %s", req.URL.Host)
|
||||
@@ -319,7 +317,6 @@ func TestFleetGetXMRPriceFetchSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFleetGetXMRPriceFetchNetworkError(t *testing.T) {
|
||||
resetXMRPriceCache(t)
|
||||
setMockHTTPTransport(t, func(req *http.Request) (*http.Response, error) {
|
||||
return nil, errors.New("network down")
|
||||
})
|
||||
@@ -333,7 +330,6 @@ func TestFleetGetXMRPriceFetchNetworkError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFleetGetXMRPriceParseError(t *testing.T) {
|
||||
resetXMRPriceCache(t)
|
||||
setMockHTTPTransport(t, func(req *http.Request) (*http.Response, error) {
|
||||
rec := httptest.NewRecorder()
|
||||
rec.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user