Skip to content

Commit a110d30

Browse files
committed
fix test
1 parent 87f57b4 commit a110d30

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

tools/generator-go-sdk/generator/templater_id_parser_test.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,8 @@ func ParseConstantOnlyID(input string) (*ConstantOnlyId, error) {
227227
}
228228
229229
id := ConstantOnlyId{}
230-
231-
if v, ok := parsed.Parsed["thingId"]; true {
232-
if !ok {
233-
return nil, resourceids.NewSegmentNotSpecifiedError(id, "thingId", *parsed)
234-
}
235-
236-
thingId, err := parseThing(v)
237-
if err != nil {
238-
return nil, fmt.Errorf("parsing %q: %+v", v, err)
239-
}
240-
id.ThingId = *thingId
230+
if err := id.FromParseResult(*parsed); err != nil {
231+
return nil, err
241232
}
242233
243234
return &id, nil
@@ -253,22 +244,27 @@ func ParseConstantOnlyIDInsensitively(input string) (*ConstantOnlyId, error) {
253244
}
254245
255246
id := ConstantOnlyId{}
256-
257-
if v, ok := parsed.Parsed["thingId"]; true {
258-
if !ok {
259-
return nil, resourceids.NewSegmentNotSpecifiedError(id, "thingId", *parsed)
260-
}
261-
262-
thingId, err := parseThing(v)
263-
if err != nil {
264-
return nil, fmt.Errorf("parsing %q: %+v", v, err)
265-
}
266-
id.ThingId = *thingId
247+
if err := id.FromParseResult(*parsed); err != nil {
248+
return nil, err
267249
}
268250
269251
return &id, nil
270252
}
271253
254+
func (id *ConstantOnlyId) FromParseResult(input resourceids.ParseResult) error {
255+
if v, ok := input.Parsed["thingId"]; true {
256+
if !ok {
257+
return resourceids.NewSegmentNotSpecifiedError(id, "thingId", input)
258+
}
259+
thingId, err := parseThing(v)
260+
if err != nil {
261+
return fmt.Errorf("parsing %q: %+v", v, err)
262+
}
263+
id.ThingId = *thingId
264+
}
265+
return nil
266+
}
267+
272268
// ValidateConstantOnlyID checks that 'input' can be parsed as a Constant Only ID
273269
func ValidateConstantOnlyID(input interface{}, key string) (warnings []string, errors []error) {
274270
v, ok := input.(string)

0 commit comments

Comments
 (0)