Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from shuheiktgw/fix_to_return_pointer
Browse files Browse the repository at this point in the history
Change props to pointer
  • Loading branch information
shuheiktgw authored May 5, 2019
2 parents af95b79 + d6ea343 commit 8047257
Show file tree
Hide file tree
Showing 62 changed files with 357 additions and 385 deletions.
4 changes: 2 additions & 2 deletions active_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestActiveService_FindByOwner(t *testing.T) {
t.Errorf("Active.FindByOwner returned error: %v", err)
}

want := []*Build{{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}}
want := []*Build{{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}}
if !reflect.DeepEqual(builds, want) {
t.Errorf("Active.FindByOwner returned %+v, want %+v", builds, want)
}
Expand All @@ -56,7 +56,7 @@ func TestActiveService_FindByGitHubId(t *testing.T) {
t.Errorf("Active.FindByGitHubId returned error: %v", err)
}

want := []*Build{{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}}
want := []*Build{{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}}
if !reflect.DeepEqual(builds, want) {
t.Errorf("Active.FindByGitHubId returned %+v, want %+v", builds, want)
}
Expand Down
10 changes: 5 additions & 5 deletions beta_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type BetaFeaturesService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/beta_feature#attributes
type BetaFeature struct {
// Value uniquely identifying the beta feature
Id uint `json:"id,omitempty"`
Id *uint `json:"id,omitempty"`
// The name of the feature
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// Longer description of the feature
Description string `json:"description,omitempty"`
Description *string `json:"description,omitempty"`
// Indicates if the user has this feature turned on
Enabled bool `json:"enabled,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
// Url for users to leave Travis CI feedback on this feature
FeedbackUrl string `json:"feedback_url,omitempty"`
FeedbackUrl *string `json:"feedback_url,omitempty"`
*Metadata
}

Expand Down
6 changes: 3 additions & 3 deletions beta_features_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestBetaFeaturesService_Integration_Update(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if feature.Id != integrationBetaFeatureId || feature.Enabled != true {
if *feature.Id != integrationBetaFeatureId || *feature.Enabled != true {
t.Fatalf("unexpected beta feature has returned: %v", feature)
}

Expand All @@ -55,7 +55,7 @@ func TestBetaFeaturesService_Integration_Update(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if feature.Id != integrationBetaFeatureId || feature.Enabled != false {
if *feature.Id != integrationBetaFeatureId || *feature.Enabled != false {
t.Fatalf("unexpected beta feature has returned: %v", feature)
}
}
Expand All @@ -82,7 +82,7 @@ func TestBetaFeaturesService_Integration_Delete(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if got, want := int(f.Id), integrationBetaFeatureId; got != want {
if got, want := int(*f.Id), integrationBetaFeatureId; got != want {
t.Fatalf("invalid beta feature id: got %d, want: %d", got, want)
}
}
6 changes: 3 additions & 3 deletions beta_features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestBetaFeaturesService_List(t *testing.T) {
t.Errorf("BetaFeatures.List returned error: %v", err)
}

want := []*BetaFeature{{Id: 1, Name: "dashboard", Description: "Try the new personal Dashboard layout", Enabled: true, FeedbackUrl: "https://github.com/travis-ci/beta-features/issues/5"}}
want := []*BetaFeature{{Id: Uint(1), Name: String("dashboard"), Description: String("Try the new personal Dashboard layout"), Enabled: Bool(true), FeedbackUrl: String("https://github.com/travis-ci/beta-features/issues/5")}}
if !reflect.DeepEqual(features, want) {
t.Errorf("BetaFeatures.List returned %+v, want %+v", features, want)
}
Expand All @@ -50,7 +50,7 @@ func TestBetaFeaturesService_Update(t *testing.T) {
t.Errorf("BetaFeatures.Update returned error: %v", err)
}

want := &BetaFeature{Id: 1, Name: "dashboard", Description: "Try the new personal Dashboard layout", Enabled: true, FeedbackUrl: "https://github.com/travis-ci/beta-features/issues/5"}
want := &BetaFeature{Id: Uint(1), Name: String("dashboard"), Description: String("Try the new personal Dashboard layout"), Enabled: Bool(true), FeedbackUrl: String("https://github.com/travis-ci/beta-features/issues/5")}
if !reflect.DeepEqual(features, want) {
t.Errorf("BetaFeatures.Update returned %+v, want %+v", features, want)
}
Expand All @@ -71,7 +71,7 @@ func TestBetaFeaturesService_Delete(t *testing.T) {
t.Errorf("BetaFeatures.Delete returned error: %v", err)
}

want := &BetaFeature{Id: 1, Name: "dashboard", Description: "Try the new personal Dashboard layout", Enabled: true, FeedbackUrl: "https://github.com/travis-ci/beta-features/issues/5"}
want := &BetaFeature{Id: Uint(1), Name: String("dashboard"), Description: String("Try the new personal Dashboard layout"), Enabled: Bool(true), FeedbackUrl: String("https://github.com/travis-ci/beta-features/issues/5")}
if !reflect.DeepEqual(features, want) {
t.Errorf("BetaFeatures.Delete returned %+v, want %+v", features, want)
}
Expand Down
10 changes: 5 additions & 5 deletions beta_migration_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type BetaMigrationRequestsService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/beta_migration_request#attributes
type BetaMigrationRequest struct {
// The beta_migration_request's id
Id uint `json:"id,omitempty"`
Id *uint `json:"id,omitempty"`
// The beta_migration_request's owner_id
OwnerId uint `json:"owner_id,omitempty"`
OwnerId *uint `json:"owner_id,omitempty"`
// The beta_migration_request's owner_name
OwnerName string `json:"owner_name,omitempty"`
OwnerName *string `json:"owner_name,omitempty"`
// Longer description of the feature
OwnerType string `json:"owner_type,omitempty"`
OwnerType *string `json:"owner_type,omitempty"`
// The beta_migration_request's accepted_at
AcceptedAt string `json:"accepted_at,omitempty"`
AcceptedAt *string `json:"accepted_at,omitempty"`
// The beta_migration_request's organizations
Organizations []*Organization `json:"organizations,omitempty"`
*Metadata
Expand Down
2 changes: 1 addition & 1 deletion beta_migration_requests_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestBetaMigrationRequestsService_Integration_Create(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if got, want := request.OwnerName, integrationGitHubOwner; got != want {
if got, want := *request.OwnerName, integrationGitHubOwner; got != want {
t.Fatalf("invalid owner: got: %s, want: %s", got, want)
}
}
4 changes: 2 additions & 2 deletions beta_migration_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestBetaMigrationRequestsService_List(t *testing.T) {
t.Errorf("BetaMigrationRequest.List returned error: %v", err)
}

want := []*BetaMigrationRequest{{Id: 1, OwnerId: 2, OwnerName: "test", OwnerType: "User"}}
want := []*BetaMigrationRequest{{Id: Uint(1), OwnerId: Uint(2), OwnerName: String("test"), OwnerType: String("User")}}
if !reflect.DeepEqual(requests, want) {
t.Errorf("BetaMigrationRequest.List returned %+v, want %+v", requests, want)
}
Expand All @@ -53,7 +53,7 @@ func TestBetaMigrationRequestsService_Create(t *testing.T) {
t.Errorf("BetaMigrationRequests.Create returned error: %v", err)
}

want := &BetaMigrationRequest{Id: 1, OwnerId: 2, OwnerName: "test", OwnerType: "User"}
want := &BetaMigrationRequest{Id: Uint(1), OwnerId: Uint(2), OwnerName: String("test"), OwnerType: String("User")}
if !reflect.DeepEqual(request, want) {
t.Errorf("BetaMigrationRequests.Create returned %+v, want %+v", request, want)
}
Expand Down
6 changes: 3 additions & 3 deletions branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ type BranchesService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/branch#standard-representation
type Branch struct {
// Name of the git branch
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// GitHub Repository
Repository *Repository `json:"repository,omitempty"`
// Whether or not this is the repository's default branch
DefaultBranch bool `json:"default_branch,omitempty"`
DefaultBranch *bool `json:"default_branch,omitempty"`
// Whether or not the branch still exists on GitHub
ExistsOnGithub bool `json:"exists_on_github,omitempty"`
ExistsOnGithub *bool `json:"exists_on_github,omitempty"`
// Last build on the branch
LastBuild *Build `json:"last_build,omitempty"`
// Last 10 builds on the branch (when `include=branch.recent_builds` is used)
Expand Down
8 changes: 4 additions & 4 deletions branches_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func TestBranchesService_Integration_FindByRepoId(t *testing.T) {
t.Fatalf("#invalid http status: %s", res.Status)
}

if branch.Name != "master" {
if *branch.Name != "master" {
t.Fatalf("unexpected branch returned: want %s: got %s", "master", branch.Name)
}

if branch.Repository.Id != integrationRepoId {
if *branch.Repository.Id != integrationRepoId {
t.Fatalf("unexpected branch returned: want %d: got %d", integrationRepoId, branch.Repository.Id)
}

Expand All @@ -53,11 +53,11 @@ func TestBranchesService_Integration_FindByRepoSlug(t *testing.T) {
t.Fatalf("#invalid http status: %s", res.Status)
}

if branch.Name != "master" {
if *branch.Name != "master" {
t.Fatalf("unexpected branch returned: want %s: got %s", "master", branch.Name)
}

if branch.Repository.Slug != integrationRepoSlug {
if *branch.Repository.Slug != integrationRepoSlug {
t.Fatalf("unexpected branch returned: want %s: got %s", integrationRepoSlug, branch.Repository.Slug)
}

Expand Down
8 changes: 4 additions & 4 deletions branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestBranchesService_FindByRepoId(t *testing.T) {
t.Errorf("Branch.FindByRepoId returned error: %v", err)
}

want := &Branch{Name: "master", Repository: &Repository{Id: 1, Name: "test", Slug: "shuheiktgw/test"}, DefaultBranch: true, ExistsOnGithub: true}
want := &Branch{Name: String("master"), Repository: &Repository{Id: Uint(1), Name: String("test"), Slug: String("shuheiktgw/test")}, DefaultBranch: Bool(true), ExistsOnGithub: Bool(true)}
if !reflect.DeepEqual(branch, want) {
t.Errorf("Branch.FindByRepoId returned %+v, want %+v", branch, want)
}
Expand All @@ -60,7 +60,7 @@ func TestBranchesService_FindByRepoSlug(t *testing.T) {
t.Errorf("Branch.FindByRepoId returned error: %v", err)
}

want := &Branch{Name: "master", Repository: &Repository{Id: 1, Name: "test", Slug: "shuheiktgw/test"}, DefaultBranch: true, ExistsOnGithub: true}
want := &Branch{Name: String("master"), Repository: &Repository{Id: Uint(1), Name: String("test"), Slug: String("shuheiktgw/test")}, DefaultBranch: Bool(true), ExistsOnGithub: Bool(true)}
if !reflect.DeepEqual(branch, want) {
t.Errorf("Branch.FindByRepoId returned %+v, want %+v", branch, want)
}
Expand All @@ -83,7 +83,7 @@ func TestBranchesService_ListByRepoId(t *testing.T) {
t.Errorf("Branches.FindByRepoId returned error: %v", err)
}

want := []*Branch{{Name: "master", Repository: &Repository{Id: 1, Name: "test", Slug: "shuheiktgw/test"}, DefaultBranch: true, ExistsOnGithub: true}}
want := []*Branch{{Name: String("master"), Repository: &Repository{Id: Uint(1), Name: String("test"), Slug: String("shuheiktgw/test")}, DefaultBranch: Bool(true), ExistsOnGithub: Bool(true)}}
if !reflect.DeepEqual(branches, want) {
t.Errorf("Branchse.FindByRepoId returned %+v, want %+v", branches, want)
}
Expand All @@ -106,7 +106,7 @@ func TestBranchesService_ListByRepoSlug(t *testing.T) {
t.Errorf("Branches.indByRepoSlug returned error: %v", err)
}

want := []*Branch{{Name: "master", Repository: &Repository{Id: 1, Name: "test", Slug: "shuheiktgw/test"}, DefaultBranch: true, ExistsOnGithub: true}}
want := []*Branch{{Name: String("master"), Repository: &Repository{Id: Uint(1), Name: String("test"), Slug: String("shuheiktgw/test")}, DefaultBranch: Bool(true), ExistsOnGithub: Bool(true)}}
if !reflect.DeepEqual(branches, want) {
t.Errorf("Branchse.indByRepoSlug returned %+v, want %+v", branches, want)
}
Expand Down
10 changes: 5 additions & 5 deletions broadcasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type BroadcastsService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/broadcast#standard-representation
type Broadcast struct {
// Value uniquely identifying the broadcast
Id uint `json:"id,omitempty"`
Id *uint `json:"id,omitempty"`
// Message to display to the user
Message string `json:"message,omitempty"`
Message *string `json:"message,omitempty"`
// Broadcast category (used for icon and color)
Category string `json:"category,omitempty"`
Category *string `json:"category,omitempty"`
// Whether or not the broadcast should still be displayed
Active bool `json:"active,omitempty"`
Active *bool `json:"active,omitempty"`
// When the broadcast was created
CreatedAt string `json:"created_at,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
// Either a user, organization or repository, or null for global
Recipient interface{} `json:"recipient,omitempty"`
*Metadata
Expand Down
2 changes: 1 addition & 1 deletion broadcasts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestBroadcastsService_List(t *testing.T) {
t.Errorf("Broadcasts.List returned error: %v", err)
}

want := []*Broadcast{{Id: 125, Message: "We just switched the default image for", Active: true, CreatedAt: "2014-11-19T14:39:51Z"}}
want := []*Broadcast{{Id: Uint(125), Message: String("We just switched the default image for"), Active: Bool(true), CreatedAt: String("2014-11-19T14:39:51Z")}}
if !reflect.DeepEqual(broadcasts, want) {
t.Errorf("Broadcasts.List returned %+v, want %+v", broadcasts, want)
}
Expand Down
24 changes: 12 additions & 12 deletions builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ type BuildsService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/build#standard-representation
type Build struct {
// Value uniquely identifying the build
Id uint `json:"id,omitempty"`
Id *uint `json:"id,omitempty"`
// Incremental number for a repository's builds
Number string `json:"number,omitempty"`
Number *string `json:"number,omitempty"`
// Current state of the build
State string `json:"state,omitempty"`
State *string `json:"state,omitempty"`
// Wall clock time in seconds
Duration uint `json:"duration,omitempty"`
Duration *uint `json:"duration,omitempty"`
// Event that triggered the build
EventType string `json:"event_type,omitempty"`
EventType *string `json:"event_type,omitempty"`
// State of the previous build (useful to see if state changed)
PreviousState string `json:"previous_state,omitempty"`
PreviousState *string `json:"previous_state,omitempty"`
// Title of the build's pull request
PullRequestTitle string `json:"pull_request_title,omitempty"`
PullRequestTitle *string `json:"pull_request_title,omitempty"`
// Number of the build's pull request
PullRequestNumber uint `json:"pull_request_number,omitempty"`
PullRequestNumber *uint `json:"pull_request_number,omitempty"`
// When the build started
StartedAt string `json:"started_at,omitempty"`
StartedAt *string `json:"started_at,omitempty"`
// When the build finished
FinishedAt string `json:"finished_at,omitempty"`
FinishedAt *string `json:"finished_at,omitempty"`
// The last time the build was updated
UpdatedAt string `json:"updated_at,omitempty"`
UpdatedAt *string `json:"updated_at,omitempty"`
// Whether or not the build is private
Private bool `json:"private,omitempty"`
Private *bool `json:"private,omitempty"`
// GitHub repository the build is associated with
Repository *Repository `json:"repository,omitempty"`
// The branch the build is associated with
Expand Down
6 changes: 3 additions & 3 deletions builds_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestBuildService_Integration_Find(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if build.Id != integrationBuildId {
if *build.Id != integrationBuildId {
t.Fatalf("unexpected job returned: want job id %d: got job id %d", integrationBuildId, build.Id)
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestBuildService_Integration_RestartAndCancel(t *testing.T) {
t.Fatalf("#invalid http status: %s", res.Status)
}

if build.Id != integrationBuildId {
if *build.Id != integrationBuildId {
t.Fatalf("unexpected job returned: want job id %d: got job id %d", integrationBuildId, build.Id)
}

Expand All @@ -151,7 +151,7 @@ func TestBuildService_Integration_RestartAndCancel(t *testing.T) {
t.Fatalf("invalid http status: %s", res.Status)
}

if build.Id != integrationBuildId {
if *build.Id != integrationBuildId {
t.Fatalf("unexpected job returned: want job id %d: got job id %d", integrationBuildId, build.Id)
}
}
12 changes: 6 additions & 6 deletions builds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestBuildsService_Find(t *testing.T) {
t.Errorf("Build.Find returned error: %v", err)
}

want := &Build{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}
want := &Build{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}
if !reflect.DeepEqual(build, want) {
t.Errorf("Build.Find returned %+v, want %+v", build, want)
}
Expand All @@ -53,7 +53,7 @@ func TestBuildsService_List(t *testing.T) {
t.Errorf("Builds.Find returned error: %v", err)
}

want := []*Build{{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}}
want := []*Build{{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}}
if !reflect.DeepEqual(builds, want) {
t.Errorf("Builds.Find returned %+v, want %+v", builds, want)
}
Expand All @@ -75,7 +75,7 @@ func TestBuildsService_ListByRepoId(t *testing.T) {
t.Errorf("Builds.FindByRepoId returned error: %v", err)
}

want := []*Build{{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}}
want := []*Build{{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}}
if !reflect.DeepEqual(builds, want) {
t.Errorf("Builds.FindByRepoId returned %+v, want %+v", builds, want)
}
Expand All @@ -97,7 +97,7 @@ func TestBuildsService_ListByRepoSlug(t *testing.T) {
t.Errorf("Builds.FindByRepoSlug returned error: %v", err)
}

want := []*Build{{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}}
want := []*Build{{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}}
if !reflect.DeepEqual(builds, want) {
t.Errorf("Builds.FindByRepoSlug returned %+v, want %+v", builds, want)
}
Expand All @@ -118,7 +118,7 @@ func TestBuildsService_Cancel(t *testing.T) {
t.Errorf("Build.Cancel returned error: %v", err)
}

want := &Build{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}
want := &Build{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}
if !reflect.DeepEqual(build, want) {
t.Errorf("Build.Cancel returned %+v, want %+v", build, want)
}
Expand All @@ -139,7 +139,7 @@ func TestBuildsService_Restart(t *testing.T) {
t.Errorf("Build.Restart returned error: %v", err)
}

want := &Build{Id: testBuildId, Number: "1", State: BuildStateCreated, Duration: 10}
want := &Build{Id: Uint(testBuildId), Number: String("1"), State: String(BuildStateCreated), Duration: Uint(10)}
if !reflect.DeepEqual(build, want) {
t.Errorf("Build.Restart returned %+v, want %+v", build, want)
}
Expand Down
4 changes: 2 additions & 2 deletions caches.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ type CachesService struct {
// Travis CI API docs: https://developer.travis-ci.com/resource/caches#attributes
type Cache struct {
// The branch the cache belongs to
Branch string `json:"branch,omitempty"`
Branch *string `json:"branch,omitempty"`
// The string to match against the cache name
Match string `json:"match,omitempty"`
Match *string `json:"match,omitempty"`
*Metadata
}

Expand Down
Loading

0 comments on commit 8047257

Please sign in to comment.