Tests.
This commit is contained in:
parent
e00e6155d7
commit
905c7258f7
@ -208,7 +208,7 @@ type (
|
|||||||
Provider string `json:"provider"` // Оператор связи
|
Provider string `json:"provider"` // Оператор связи
|
||||||
Country string `json:"country"` // Страна
|
Country string `json:"country"` // Страна
|
||||||
Region string `json:"region"` // Регион
|
Region string `json:"region"` // Регион
|
||||||
City string `json:"city"` // Город
|
City string `json:"city"` // Город (только для стационарных телефонов)
|
||||||
Timezone string `json:"timezone"` // Часовой пояс
|
Timezone string `json:"timezone"` // Часовой пояс
|
||||||
QualityCodeConflict int `json:"qc_conflict"` // Признак конфликта телефона с адресом
|
QualityCodeConflict int `json:"qc_conflict"` // Признак конфликта телефона с адресом
|
||||||
QualityCode int `json:"qc"` // Код качества
|
QualityCode int `json:"qc"` // Код качества
|
||||||
|
@ -40,3 +40,51 @@ func TestParty(t *testing.T) {
|
|||||||
assert.Equal(t, PartyFounderTypeLegal, model.Founders[0].Type)
|
assert.Equal(t, PartyFounderTypeLegal, model.Founders[0].Type)
|
||||||
assert.Equal(t, PartySMBCategorySmall, model.Documents.Smb.Category)
|
assert.Equal(t, PartySMBCategorySmall, model.Documents.Smb.Category)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPhone1(t *testing.T) {
|
||||||
|
dataReader, err := os.Open("test/phone1.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
defer dataReader.Close()
|
||||||
|
|
||||||
|
model := Phone{}
|
||||||
|
|
||||||
|
err = json.NewDecoder(dataReader).Decode(&model)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "+375123456789", model.Source)
|
||||||
|
assert.Equal(t, "Беларусь", model.Country)
|
||||||
|
assert.Equal(t, "", model.City)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPhone2(t *testing.T) {
|
||||||
|
dataReader, err := os.Open("test/phone2.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
defer dataReader.Close()
|
||||||
|
|
||||||
|
model := Phone{}
|
||||||
|
|
||||||
|
err = json.NewDecoder(dataReader).Decode(&model)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "+79851234567", model.Source)
|
||||||
|
assert.Equal(t, "Россия", model.Country)
|
||||||
|
assert.Equal(t, "", model.City)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPhone3(t *testing.T) {
|
||||||
|
dataReader, err := os.Open("test/phone3.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
defer dataReader.Close()
|
||||||
|
|
||||||
|
model := Phone{}
|
||||||
|
|
||||||
|
err = json.NewDecoder(dataReader).Decode(&model)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, "+123", model.Source)
|
||||||
|
assert.Equal(t, "", model.Country)
|
||||||
|
assert.Equal(t, "", model.City)
|
||||||
|
}
|
||||||
|
16
api/model/test/phone1.json
Normal file
16
api/model/test/phone1.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"source": "+375123456789",
|
||||||
|
"type": "Стационарный",
|
||||||
|
"phone": "+375 123456789",
|
||||||
|
"country_code": "375",
|
||||||
|
"city_code": null,
|
||||||
|
"number": "123456789",
|
||||||
|
"extension": null,
|
||||||
|
"provider": null,
|
||||||
|
"country": "Беларусь",
|
||||||
|
"region": null,
|
||||||
|
"city": null,
|
||||||
|
"timezone": "UTC+3",
|
||||||
|
"qc_conflict": 0,
|
||||||
|
"qc": 7
|
||||||
|
}
|
16
api/model/test/phone2.json
Normal file
16
api/model/test/phone2.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"source": "+79851234567",
|
||||||
|
"type": "Мобильный",
|
||||||
|
"phone": "+7 985 123-45-67",
|
||||||
|
"country_code": "7",
|
||||||
|
"city_code": "985",
|
||||||
|
"number": "1234567",
|
||||||
|
"extension": null,
|
||||||
|
"provider": "ПАО \"Мобильные ТелеСистемы\"",
|
||||||
|
"country": "Россия",
|
||||||
|
"region": "Москва и Московская область",
|
||||||
|
"city": null,
|
||||||
|
"timezone": "UTC+3",
|
||||||
|
"qc_conflict": 0,
|
||||||
|
"qc": 0
|
||||||
|
}
|
16
api/model/test/phone3.json
Normal file
16
api/model/test/phone3.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"source": "+123",
|
||||||
|
"type": "Неизвестный",
|
||||||
|
"phone": null,
|
||||||
|
"country_code": null,
|
||||||
|
"city_code": null,
|
||||||
|
"number": null,
|
||||||
|
"extension": null,
|
||||||
|
"provider": null,
|
||||||
|
"country": null,
|
||||||
|
"region": null,
|
||||||
|
"city": null,
|
||||||
|
"timezone": null,
|
||||||
|
"qc_conflict": 0,
|
||||||
|
"qc": 1
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user