Skip to content

Commit

Permalink
Split test cases to check different type format in api response
Browse files Browse the repository at this point in the history
  • Loading branch information
kk-no committed Dec 28, 2023
1 parent f63eee7 commit 954c673
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions company_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,58 @@ func TestCompanyServiceOp_Get(t *testing.T) {
wantErr error
}{
{
name: "Successfully get a company",
name: "Get a company",
fields: fields{
companyPath: hubspot.ExportCompanyBasePath,
client: hubspot.NewMockClient(&hubspot.MockConfig{
Status: http.StatusOK,
Header: http.Header{},
Body: []byte(`{"id":"company001","properties":{"annualrevenue":"1000000","city":"Cambridge","createdate":"2019-10-30T03:30:17.883Z","domain":"biglytics.net","hs_lastmodifieddate":"2019-12-07T16:50:06.678Z","industry":"Technology","name":"Biglytics","phone":"(877)929-0687","state":"Massachusetts","custom_name":"biglytics","custom_date":"2019-10-30T03:30:17.883Z","hs_created_by_user_id":"","twitterfollowers":1000},"createdAt":"2019-10-30T03:30:17.883Z","updatedAt":"2019-12-07T16:50:06.678Z"}`),
Body: []byte(`{"id":"company001","properties":{"annualrevenue":"1000000","city":"Cambridge","createdate":"2019-10-30T03:30:17.883Z","domain":"biglytics.net","hs_lastmodifieddate":"2019-12-07T16:50:06.678Z","industry":"Technology","name":"Biglytics","phone":"(877)929-0687","state":"Massachusetts","custom_name":"biglytics","custom_date":"2019-10-30T03:30:17.883Z","hs_created_by_user_id":""},"createdAt":"2019-10-30T03:30:17.883Z","updatedAt":"2019-12-07T16:50:06.678Z"}`),
}),
},
args: args{
companyID: "company001",
company: &CustomFields{},
option: &hubspot.RequestQueryOption{
Properties: []string{
"custom_name",
"custom_date",
},
},
},
want: &hubspot.ResponseResource{
ID: "company001",
Archived: false,
Properties: &CustomFields{
Company: hubspot.Company{
Annualrevenue: hubspot.NewInt(1000000),
City: hubspot.NewString("Cambridge"),
Createdate: &createdAt,
Domain: hubspot.NewString("biglytics.net"),
HsLastmodifieddate: &updatedAt,
Industry: hubspot.NewString("Technology"),
Name: hubspot.NewString("Biglytics"),
Phone: hubspot.NewString("(877)929-0687"),
State: hubspot.NewString("Massachusetts"),
HsCreatedByUserId: hubspot.NewInt(0),
},
CustomName: hubspot.NewString("biglytics"),
CustomDate: &createdAt,
},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
},
wantErr: nil,
},
{
name: "If the API returns a numeric value when getting a company",
fields: fields{
companyPath: hubspot.ExportCompanyBasePath,
client: hubspot.NewMockClient(&hubspot.MockConfig{
Status: http.StatusOK,
Header: http.Header{},
// NOTE: Normally, numeric types in the HubSpot API are returned as strings (e.g. "", "12345"), but this is to confirm when they are returned as numbers.
Body: []byte(`{"id":"company001","properties":{"annualrevenue":1000000,"city":"Cambridge","createdate":"2019-10-30T03:30:17.883Z","domain":"biglytics.net","hs_lastmodifieddate":"2019-12-07T16:50:06.678Z","industry":"Technology","name":"Biglytics","phone":"(877)929-0687","state":"Massachusetts","custom_name":"biglytics","custom_date":"2019-10-30T03:30:17.883Z","hs_created_by_user_id":0},"createdAt":"2019-10-30T03:30:17.883Z","updatedAt":"2019-12-07T16:50:06.678Z"}`),
}),
},
args: args{
Expand Down Expand Up @@ -257,7 +302,6 @@ func TestCompanyServiceOp_Get(t *testing.T) {
Phone: hubspot.NewString("(877)929-0687"),
State: hubspot.NewString("Massachusetts"),
HsCreatedByUserId: hubspot.NewInt(0),
Twitterfollowers: hubspot.NewInt(1000),
},
CustomName: hubspot.NewString("biglytics"),
CustomDate: &createdAt,
Expand Down

0 comments on commit 954c673

Please sign in to comment.