26 lines
827 B
Go
26 lines
827 B
Go
package locations
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLocationResponseSchemaIsPrivateAndStructural(t *testing.T) {
|
|
schema, err := loadResponseSchema()
|
|
if err != nil {
|
|
t.Fatalf("loadResponseSchema() error = %v", err)
|
|
}
|
|
if schema.Key != ResponseSchemaKey || schema.ID != ResponseSchemaID || schema.Name != ResponseSchemaName || schema.Version != SchemaVersion || !strings.HasPrefix(schema.SHA256, "sha256:") || !json.Valid(schema.JSONSchema) {
|
|
t.Fatalf("schema = %#v, want location response schema", schema)
|
|
}
|
|
var document map[string]any
|
|
if err := json.Unmarshal(schema.JSONSchema, &document); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
encoded, err := json.Marshal(document)
|
|
if err != nil || strings.Contains(string(encoded), `"id"`) {
|
|
t.Fatalf("schema = %s, want no durable ID field", encoded)
|
|
}
|
|
}
|