(t *testing.T)
| 16 | const websiteURLInvalidCharErrSubstr = "websiteUrl contains an invalid character" |
| 17 | |
| 18 | func TestValidate(t *testing.T) { |
| 19 | tests := []struct { |
| 20 | name string |
| 21 | serverDetail apiv0.ServerJSON |
| 22 | expectedError string |
| 23 | }{ |
| 24 | { |
| 25 | name: "Schema version is required", |
| 26 | serverDetail: apiv0.ServerJSON{ |
| 27 | Name: "com.example/test-server", |
| 28 | Description: "A test server", |
| 29 | Repository: &model.Repository{ |
| 30 | URL: "https://github.com/owner/repo", |
| 31 | Source: "github", |
| 32 | }, |
| 33 | Version: "1.0.0", |
| 34 | }, |
| 35 | expectedError: "$schema field is required", |
| 36 | }, |
| 37 | { |
| 38 | name: "Schema version rejects old schema (2025-01-27) - non-existent version", |
| 39 | serverDetail: apiv0.ServerJSON{ |
| 40 | Schema: "https://static.modelcontextprotocol.io/schemas/2025-01-27/server.schema.json", |
| 41 | Name: "com.example/test-server", |
| 42 | Description: "A test server", |
| 43 | Repository: &model.Repository{ |
| 44 | URL: "https://github.com/owner/repo", |
| 45 | Source: "github", |
| 46 | }, |
| 47 | Version: "1.0.0", |
| 48 | }, |
| 49 | // This schema version doesn't exist in embedded schemas, so validation should fail |
| 50 | // ValidateServerJSON with ValidationSchemaVersionAndSemantic validates that the schema version exists |
| 51 | expectedError: "schema version 2025-01-27 not found in embedded schemas", |
| 52 | }, |
| 53 | { |
| 54 | name: "Schema version accepts current schema (2025-10-17)", |
| 55 | serverDetail: apiv0.ServerJSON{ |
| 56 | Schema: model.CurrentSchemaURL, |
| 57 | Name: "com.example/test-server", |
| 58 | Description: "A test server", |
| 59 | Repository: &model.Repository{ |
| 60 | URL: "https://github.com/owner/repo", |
| 61 | Source: "github", |
| 62 | }, |
| 63 | Version: "1.0.0", |
| 64 | }, |
| 65 | expectedError: "", |
| 66 | }, |
| 67 | { |
| 68 | name: "Version rejects top-level version ranges", |
| 69 | serverDetail: apiv0.ServerJSON{ |
| 70 | Schema: model.CurrentSchemaURL, |
| 71 | Name: "com.example/test-server", |
| 72 | Description: "A test server", |
| 73 | Repository: &model.Repository{ |
| 74 | URL: "https://github.com/owner/repo", |
| 75 | Source: "github", |
nothing calls this directly
no test coverage detected
searching dependent graphs…