Я пытаюсь выучить Golang тестирование.
Я сравниваю 2, казалось бы, идентичных элемента, но они не равны. Что не так?
2020/01/22 17:10:10 ****2 cities[0] is type *main.City has &main.City{Name:"Boston", State:"", Country:"USA", Capital:true, Population:685000}
2020/01/22 17:10:10 ****2 expected is type *main.City has &main.City{Name:"Boston", State:"", Country:"USA", Capital:true, Population:685000}
2020/01/22 17:10:11 Preparing to DELETE 5 city docs
--- FAIL: TestCities (3.08s)
--- FAIL: TestCities/Test_POST_should_add_New_City (0.62s)
city_handlers_test.go:68: Why is ( cities[0] != expected )Boston was not added to Firestore:
got &{Boston USA true 685000}
want &{Boston USA true 685000}
FAIL
exit status 1
Вот тест:
// why don't these structs match?
log.Printf("****2 cities[0] is type %T has %#v \n", cities[0], cities[0])
log.Printf("****2 expected is type %T has %#v \n", expected, expected)
// why is this comparison failing when both are the same type with the same values?
if cities[0] != expected {
t.Errorf("Why is ( cities[0] != expected )Boston was not added to Firestore: \n got %v \n want %v", cities[0], expected)
}