1
0
Fork 0
mirror of https://code.forgejo.org/actions/ovh-dns-update synced 2025-06-08 04:58:21 +02:00

better check

This commit is contained in:
oliverpool 2023-08-19 20:20:27 +02:00
parent 1e88a41e80
commit 35397949f8
2 changed files with 12 additions and 4 deletions

View file

@ -33,5 +33,5 @@ jobs:
ovh-consumer-key: CON_KEY ovh-consumer-key: CON_KEY
- name: check record update - name: check record update
run: | run: |
echo ${{ steps.test.outputs.DNS_TXT }} cat dns.txt
test ${{ steps.test.outputs.DNS_TXT }} = "v1.42" grep --quiet "v=v1.42" dns.txt

View file

@ -58,6 +58,7 @@ func TestRun(t *testing.T) {
msg := fmt.Sprintf("unexpected request on %s", r.URL.Path) msg := fmt.Sprintf("unexpected request on %s", r.URL.Path)
http.Error(w, msg, http.StatusBadRequest) http.Error(w, msg, http.StatusBadRequest)
t.Error(msg) t.Error(msg)
return
case "/auth/time": case "/auth/time":
case "/domain/zone/example.org/record/12345": case "/domain/zone/example.org/record/12345":
var body struct { var body struct {
@ -69,13 +70,20 @@ func TestRun(t *testing.T) {
msg := fmt.Sprintf("could not decode request body: %v", err) msg := fmt.Sprintf("could not decode request body: %v", err)
http.Error(w, msg, http.StatusBadRequest) http.Error(w, msg, http.StatusBadRequest)
t.Error(msg) t.Error(msg)
return
} }
if body.SubDomain != "_release" { if body.SubDomain != "_release" {
msg := fmt.Sprintf("unexpected subdomain: %s", body.SubDomain) msg := fmt.Sprintf("unexpected subdomain: %s", body.SubDomain)
http.Error(w, msg, http.StatusBadRequest) http.Error(w, msg, http.StatusBadRequest)
t.Error(msg) t.Error(msg)
} else { return
githubactions.SetOutput("DNS_TXT", body.Target) }
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
} }
} }
})) }))