Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/entities/contact_test.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/entities/contact_test.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/entities/contact_test.go
-
curl -L -o contact_test.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/entities/contact_test.go
1.63 kB
| package entities | |
| import ( | |
| "reflect" | |
| "testing" | |
| "github.com/stretchr/testify/assert" | |
| ) | |
| func TestContact_BSONFieldNames(t *testing.T) { | |
| contactType := reflect.TypeOf(Contact{}) | |
| expected := map[string]string{ | |
| "ID": "_id", | |
| "UserID": "user_id", | |
| "Name": "name", | |
| "Emails": "emails", | |
| "PhoneNumbers": "phone_numbers", | |
| "Properties": "properties", | |
| "CreatedAt": "created_at", | |
| "UpdatedAt": "updated_at", | |
| } | |
| for fieldName, bsonName := range expected { | |
| field, found := contactType.FieldByName(fieldName) | |
| assert.True(t, found) | |
| assert.Equal(t, bsonName, field.Tag.Get("bson")) | |
| } | |
| } | |
| func TestContactProperties_ValueScanRoundTrip(t *testing.T) { | |
| cases := []ContactProperties{ | |
| nil, | |
| {}, | |
| {"company": "Acme", "role": "CTO"}, | |
| } | |
| for _, original := range cases { | |
| value, err := original.Value() | |
| assert.Nil(t, err) | |
| var scanned ContactProperties | |
| assert.Nil(t, scanned.Scan(value)) | |
| if len(original) == 0 { | |
| assert.Equal(t, 0, len(scanned)) | |
| continue | |
| } | |
| assert.Equal(t, original, scanned) | |
| } | |
| } | |
| func TestContactProperties_ScanFromString(t *testing.T) { | |
| var scanned ContactProperties | |
| assert.Nil(t, scanned.Scan(`{"k":"v"}`)) | |
| assert.Equal(t, ContactProperties{"k": "v"}, scanned) | |
| } | |
| func TestContactProperties_ScanNil(t *testing.T) { | |
| var scanned ContactProperties | |
| assert.Nil(t, scanned.Scan(nil)) | |
| assert.Equal(t, 0, len(scanned)) | |
| } | |
| func TestContactProperties_ScanUnsupportedType(t *testing.T) { | |
| var scanned ContactProperties | |
| err := scanned.Scan(123) | |
| assert.Error(t, err) | |
| assert.Contains(t, err.Error(), "unsupported type [int] for ContactProperties") | |
| } | |