mirror of
https://code.forgejo.org/actions/ovh-dns-update
synced 2025-03-15 06:46:59 +01:00
check DNS_TXT
This commit is contained in:
parent
105a5e79af
commit
1e88a41e80
2 changed files with 15 additions and 4 deletions
|
@ -31,3 +31,7 @@ jobs:
|
|||
ovh-app-key: APP_KEY
|
||||
ovh-app-secret: APP_SECRET
|
||||
ovh-consumer-key: CON_KEY
|
||||
- name: check record update
|
||||
run: |
|
||||
echo ${{ steps.test.outputs.DNS_TXT }}
|
||||
test ${{ steps.test.outputs.DNS_TXT }} = "v1.42"
|
||||
|
|
15
main_test.go
15
main_test.go
|
@ -4,6 +4,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -59,16 +60,22 @@ func TestRun(t *testing.T) {
|
|||
t.Error(msg)
|
||||
case "/auth/time":
|
||||
case "/domain/zone/example.org/record/12345":
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
var body struct {
|
||||
SubDomain string `json:"subDomain"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
err := json.NewDecoder(r.Body).Decode(&body)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("could not read request body: %v", err)
|
||||
msg := fmt.Sprintf("could not decode request body: %v", err)
|
||||
http.Error(w, msg, http.StatusBadRequest)
|
||||
t.Error(msg)
|
||||
}
|
||||
if string(buf) != `{"subDomain":"_release","target":"\"v=1.42\""}` {
|
||||
msg := fmt.Sprintf("unexpected body: %s", string(buf))
|
||||
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)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
|
Loading…
Add table
Reference in a new issue