mesh/repo-check head 332aa75afd19 merged into trunk 74baa5378716 beside mesh-controller#434@4357b368 — pass: its merge-check.sh passed, each part in its to…
mesh/merge-gate head 332aa75afd19 merged into trunk 74baa5378716 — pass: group fix/1826-held-config composed: every machine composes with the change as it …
mesh/delivery delivered
mesh/delivery-group group fix/1826-held-config merged: every member is merged
mesh/check failed: g14: novox/mesh-catalog#437: checks/imagebuild/go.mod cannot be read to check its mesh-sdk pin: Gitea API /repos/novox/mesh-catalog…
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// toolForge.Pull reads gitea_get_pull_request as the forge answers it (testdata/captured), bare or in the wrappings the
|
|
// runtime puts around a tool's answer.
|
|
func TestToolForgePullReadsTheCapturedAnswers(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
file string
|
|
number int
|
|
open, merged bool
|
|
head string
|
|
}{
|
|
{"get_pull_request_closed_merged_435.json", 435, false, true, "7b5f7f84acb73aaf8189200548ff69fd9aac04b2"},
|
|
{"get_pull_request_open_434.json", 434, true, false, "c948f3a61c74257e6e3147effb396d9d6434f491"},
|
|
} {
|
|
raw, err := os.ReadFile("testdata/captured/" + tc.file)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
content, _ := json.Marshal(map[string]any{"content": []map[string]any{{"type": "text", "text": string(raw)}}})
|
|
ok, _ := json.Marshal(map[string]any{"ok": true, "output": "", "answer": json.RawMessage(raw)})
|
|
for name, answer := range map[string]json.RawMessage{"bare": raw, "content list": content, "ok answer": ok} {
|
|
f := toolForge{ask: func(key string, body any) (json.RawMessage, error) { return answer, nil }}
|
|
open, merged, head, err := f.Pull("novox", "mesh-catalog", tc.number)
|
|
if err != nil || open != tc.open || merged != tc.merged || head != tc.head {
|
|
t.Errorf("%s (%s): open %v merged %v head %q, err %v", tc.file, name, open, merged, head, err)
|
|
}
|
|
}
|
|
}
|
|
}
|