accept $RECURSIVE_MISSING_WEBHOOK $RECURSIVE_MISSING_WEBHOOK_CACHE_D

This commit is contained in:
Bel LaPointe
2025-04-22 20:28:53 -06:00
parent 3e8e33816e
commit 54bbca8fea
2 changed files with 74 additions and 7 deletions

View File

@@ -3,6 +3,8 @@ package main_test
import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path"
"slices"
@@ -149,6 +151,38 @@ func TestRunWith(t *testing.T) {
}
func TestRecursive(t *testing.T) {
webhooks := []string{}
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("p") == "" {
t.Errorf("webhook wasn't called with ?p: %s", r.URL.String())
}
b, _ := ioutil.ReadAll(r.Body)
if string(b) != r.URL.Query().Get("p") {
t.Errorf("webhook wasn't called with ?p == {body}: %q vs %q", r.URL.Query().Get("p"), b)
}
webhooks = append(webhooks, string(b))
}))
t.Cleanup(s.Close)
t.Cleanup(func() {
t.Logf("webhooks: %+v", webhooks)
if len(webhooks) == 0 {
t.Errorf("expected webhook calls but got none")
}
deduped := slices.Clone(webhooks)
slices.Sort(deduped)
slices.Compact(deduped)
if len(deduped) != len(webhooks) {
t.Errorf("expected no duplicate webhooks but got %+v", webhooks)
}
})
main.WebhookOnRecursiveMiss = s.URL
main.WebhookOnRecursiveMissCacheD = t.TempDir()
t.Cleanup(func() {
main.WebhookOnRecursiveMiss = ""
main.WebhookOnRecursiveMissCacheD = ""
})
was, _ := os.Getwd()
t.Cleanup(func() { os.Chdir(was) })
os.Chdir(t.TempDir())
@@ -196,6 +230,8 @@ func TestRecursive(t *testing.T) {
if err := main.Recursive(context.Background()); err != nil {
t.Fatal(err)
} else if err := main.Recursive(context.Background()); err != nil {
t.Fatalf("failed second run: %v", err)
}
exists(t, path.Join(outd, "A", "A_SAEA.a"))