File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
api/broker/binding_request_parser Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 11package binding_request_parser_test
22
33import (
4+ "path/filepath"
5+
46 . "github.com/onsi/ginkgo/v2"
57 . "github.com/onsi/gomega"
68
@@ -49,7 +51,6 @@ var _ = Describe("BindingRequestParsers", func() {
4951 const validLegacyBindingRequestRaw string = `
5052 {
5153 "configuration": {
52- "app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",
5354 "custom_metrics": {
5455 "metric_submission_strategy": {
5556 "allow_from": "bound_app"
@@ -104,11 +105,14 @@ var _ = Describe("BindingRequestParsers", func() {
104105
105106 Describe ("LegacyBindingRequestParser" , func () {
106107 var (
107- legacyParser lp.LegacyBindingRequestParser
108- err error
108+ legacyParser lp.LegacyBindingRequestParser
109+ schemaFilePathAbs string
110+ err error
109111 )
110112 var _ = BeforeEach (func () {
111- legacyParser , err = lp .New ()
113+ schemaFilePathAbs , err = filepath .Abs ("./legacy_parser/schema.json" )
114+ Expect (err ).NotTo (HaveOccurred ())
115+ legacyParser , err = lp .New ("file://" + schemaFilePathAbs )
112116 Expect (err ).NotTo (HaveOccurred ())
113117 })
114118
Original file line number Diff line number Diff line change @@ -16,8 +16,14 @@ type LegacyBindingRequestParser struct {
1616
1717var _ binding_request_parser.Parser = LegacyBindingRequestParser {}
1818
19- func New () (LegacyBindingRequestParser , error ) {
20- const schemaFilePath string = "file://./schema.json"
19+ // New creates a new LegacyBindingRequestParser with the JSON schema loaded from the specified file
20+ // path.
21+ //
22+ // The schemaFilePath parameter should be a valid and absolute file URI (e.g.,
23+ // "file:///path/to/schema.json").
24+ //
25+ // Returns an error if the schema file cannot be loaded or parsed.
26+ func New (schemaFilePath string ) (LegacyBindingRequestParser , error ) {
2127 schemaLoader := gojsonschema .NewReferenceLoader (schemaFilePath )
2228 schema , err := gojsonschema .NewSchema (schemaLoader )
2329 if err != nil {
@@ -97,8 +103,7 @@ This must not happen because of prior schema-validation. This is a programming-e
97103 strat , err := models .ParseCustomMetricsStrategy (
98104 bindingReqParams .BindingConfig .CustomMetrics .MetricSubmissionStrategy .AllowFrom )
99105
100- if err == nil {
101-
106+ if err != nil {
102107 return models.AppScalingConfig {}, & models.InvalidArgumentError {
103108 Param : "err" ,
104109 Value : err ,
You can’t perform that action at this time.
0 commit comments