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:
parent
1e88a41e80
commit
35397949f8
2 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
|
|
12
main_test.go
12
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
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue