58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package lang
|
|
|
|
// Server and entity comparison functions for parser tests
|
|
|
|
func serverEqual(got, want Server) bool {
|
|
if got.Name != want.Name {
|
|
return false
|
|
}
|
|
|
|
if len(got.Settings) != len(want.Settings) {
|
|
return false
|
|
}
|
|
|
|
for i, setting := range got.Settings {
|
|
if !serverSettingEqual(setting, want.Settings[i]) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func serverSettingEqual(got, want ServerSetting) bool {
|
|
return stringPtrEqual(got.Host, want.Host) && intPtrEqual(got.Port, want.Port)
|
|
}
|
|
|
|
func entityEqual(got, want Entity) bool {
|
|
if got.Name != want.Name {
|
|
return false
|
|
}
|
|
|
|
if !stringPtrEqual(got.Description, want.Description) {
|
|
return false
|
|
}
|
|
|
|
if len(got.Fields) != len(want.Fields) {
|
|
return false
|
|
}
|
|
|
|
for i, field := range got.Fields {
|
|
if !fieldEqual(field, want.Fields[i]) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func endpointEqual(got, want Endpoint) bool {
|
|
return got.Method == want.Method &&
|
|
got.Path == want.Path &&
|
|
stringPtrEqual(got.Entity, want.Entity) &&
|
|
stringPtrEqual(got.Description, want.Description) &&
|
|
got.Auth == want.Auth &&
|
|
stringPtrEqual(got.CustomLogic, want.CustomLogic)
|
|
// TODO: Add params and response comparison if needed
|
|
}
|