Verify versioned contracts and exact offline distribution selection

This commit is contained in:
2026-11-29 04:35:26 +00:00
parent 053219b8da
commit e2e86a0a71
5 changed files with 184 additions and 43 deletions

View File

@@ -0,0 +1,37 @@
package validation
import (
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
)
func TestCanonicalStaticPaths(t *testing.T) {
set := loadSet(t)
server := httptest.NewServer(http.FileServer(http.Dir("../..")))
defer server.Close()
for _, record := range set.Catalog.Schemas {
t.Run(record.Name, func(t *testing.T) {
route := strings.TrimPrefix(record.ID, schemaBase)
response, err := server.Client().Get(server.URL + "/" + route)
if err != nil {
t.Fatal(err)
}
defer response.Body.Close()
got, err := io.ReadAll(response.Body)
if err != nil {
t.Fatal(err)
}
want, err := os.ReadFile("../../" + record.Path)
if err != nil {
t.Fatal(err)
}
if response.StatusCode != 200 || string(got) != string(want) {
t.Fatalf("canonical path %s did not serve the exact schema bytes", record.ID)
}
})
}
}