add bracket syntax replace tests
This commit is contained in:
57
lang/test_server_entity_comparisons.go
Normal file
57
lang/test_server_entity_comparisons.go
Normal file
@ -0,0 +1,57 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user