freeconf / restconf

Implementation of RESTCONF Management protocol - IETF RFC8040
Apache License 2.0
29 stars 9 forks source link

Duplicate/Bad test for restconf server? #6

Closed HRogge closed 1 year ago

HRogge commented 2 years ago

In server_test.go the test in line 54 seems to be wrong... the return type suggest this was meant to do a "GET" operation on the "car" data, but what the test does is to retrieve the schema of "car", exactly as the test beginning in line 51.

This can also be seen in the file testdata/gold/car.json, which doesn't contain JSON data but a YANG file.

I guess the test should be a line like: req, _ := http.NewRequest("GET", fmt.Sprintf("%s/restconf/data/car", addr), nil)

dhubler commented 1 year ago

Test is ok. It is subtle, but Accept-Type is different on lines 54 and 51 and one tests getting YANG file in it's original form and one in the JSON form. After implementing this, I have since discovered RESTCONF allows for getting YANG in original form via the ietf-yang-lib module and I hope to investigate that someday as an alternative to getting the original version. .