diff --git a/.forgejo/workflows/pr.yml b/.forgejo/workflows/pr.yml index b91bbfa..db53a74 100644 --- a/.forgejo/workflows/pr.yml +++ b/.forgejo/workflows/pr.yml @@ -33,5 +33,5 @@ jobs: ovh-consumer-key: CON_KEY - name: check record update run: | - echo ${{ steps.test.outputs.DNS_TXT }} - test ${{ steps.test.outputs.DNS_TXT }} = "v1.42" + cat dns.txt + grep --quiet "v=v1.42" dns.txt diff --git a/main_test.go b/main_test.go index 109a498..296b24f 100644 --- a/main_test.go +++ b/main_test.go @@ -58,6 +58,7 @@ func TestRun(t *testing.T) { msg := fmt.Sprintf("unexpected request on %s", r.URL.Path) http.Error(w, msg, http.StatusBadRequest) t.Error(msg) + return case "/auth/time": case "/domain/zone/example.org/record/12345": var body struct { @@ -69,13 +70,20 @@ func TestRun(t *testing.T) { msg := fmt.Sprintf("could not decode request body: %v", err) http.Error(w, msg, http.StatusBadRequest) t.Error(msg) + return } if body.SubDomain != "_release" { msg := fmt.Sprintf("unexpected subdomain: %s", body.SubDomain) http.Error(w, msg, http.StatusBadRequest) t.Error(msg) - } else { - githubactions.SetOutput("DNS_TXT", body.Target) + return + } + err = os.WriteFile("dns.txt", []byte(body.Target), 0x444) + if err != nil { + msg := fmt.Sprintf("could write dns.txt: %v", err) + http.Error(w, msg, http.StatusInternalServerError) + t.Error(msg) + return } } }))