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

Commit

Permalink
Add permissions to the part of metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuhei Kitagawa committed Oct 2, 2018
1 parent 2c63888 commit 4425a12
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
2 changes: 0 additions & 2 deletions authentication_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
)

func TestAuthenticationService_UsingGithubToken(t *testing.T) {
t.Parallel()

token, res, err := integrationClient.Authentication.UsingGithubToken(context.TODO(), integrationGitHubToken)

if err != nil {
Expand Down
53 changes: 49 additions & 4 deletions env_vars_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package travis

import (
"context"
"fmt"
"net/http"
"reflect"
"testing"
Expand Down Expand Up @@ -94,7 +95,18 @@ func TestEnvVarsService_Integration_CreateAndUpdateAndDeleteEnvVarByRepoId(t *te
t.Fatalf("EnvVars.CreateByRepoId returned invalid http status: %s", res.Status)
}

want := &EnvVar{Id: envVar.Id, Name: "TEST", Value: "test", Public: true}
want := &EnvVar{
Id: envVar.Id,
Name: "TEST",
Value: "test",
Public: true,
Metadata: Metadata{
Type: "env_var",
Href: fmt.Sprintf("/repo/20783933/env_var/%s", envVar.Id),
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}
if !reflect.DeepEqual(envVar, want) {
t.Errorf("EnvVars.CreateByRepoId returned %+v, want %+v", envVar, want)
}
Expand All @@ -114,7 +126,18 @@ func TestEnvVarsService_Integration_CreateAndUpdateAndDeleteEnvVarByRepoId(t *te
t.Fatalf("EnvVars.UpdateByRepoId returned invalid http status: %s", res.Status)
}

want = &EnvVar{Id: envVar.Id, Name: "NEW_TEST", Value: "", Public: false}
want = &EnvVar{
Id: envVar.Id,
Name: "NEW_TEST",
Value: "",
Public: false,
Metadata: Metadata{
Type: "env_var",
Href: fmt.Sprintf("/repo/20783933/env_var/%s", envVar.Id),
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}
if !reflect.DeepEqual(envVar, want) {
t.Errorf("EnvVars.UpdateByRepoId returned %+v, want %+v", envVar, want)
}
Expand Down Expand Up @@ -147,7 +170,18 @@ func TestEnvVarsService_Integration_CreateAndUpdateAndDeleteEnvVarByRepoSlug(t *
t.Fatalf("EnvVars.CreateByRepoSlug returned invalid http status: %s", res.Status)
}

want := &EnvVar{Id: envVar.Id, Name: "TEST", Value: "test", Public: true}
want := &EnvVar{
Id: envVar.Id,
Name: "TEST",
Value: "test",
Public: true,
Metadata: Metadata{
Type: "env_var",
Href: fmt.Sprintf("/repo/20783933/env_var/%s", envVar.Id),
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}
if !reflect.DeepEqual(envVar, want) {
t.Errorf("EnvVars.CreateByRepoSlug returned %+v, want %+v", envVar, want)
}
Expand All @@ -167,7 +201,18 @@ func TestEnvVarsService_Integration_CreateAndUpdateAndDeleteEnvVarByRepoSlug(t *
t.Fatalf("EnvVar.UpdateByRepoSlug returned invalid http status: %s", res.Status)
}

want = &EnvVar{Id: envVar.Id, Name: "NEW_TEST", Value: "", Public: false}
want = &EnvVar{
Id: envVar.Id,
Name: "NEW_TEST",
Value: "",
Public: false,
Metadata: Metadata{
Type: "env_var",
Href: fmt.Sprintf("/repo/20783933/env_var/%s", envVar.Id),
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}
if !reflect.DeepEqual(envVar, want) {
t.Errorf("EnvVars.UpdateByRepoSlug returned %+v, want %+v", envVar, want)
}
Expand Down
2 changes: 1 addition & 1 deletion lint_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestLintService_Integration_Lint(t *testing.T) {
}

if res.StatusCode != http.StatusOK {
t.Fatalf("#invalid http status: %s", res.Status)
t.Fatalf("invalid http status: %s", res.Status)
}

if len(warnings) == 0 {
Expand Down
4 changes: 4 additions & 0 deletions settings_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestSettingsService_Integration_FindByRepoId(t *testing.T) {
Type: "setting",
Href: "/repo/20783933/setting/builds_only_with_travis_yml",
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}

Expand All @@ -59,6 +60,7 @@ func TestSettingsService_Integration_FindByRepoSlug(t *testing.T) {
Type: "setting",
Href: "/repo/20783933/setting/builds_only_with_travis_yml",
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}

Expand Down Expand Up @@ -118,6 +120,7 @@ func TestSettingsService_Integration_UpdateByRepoIdAndSlug(t *testing.T) {
Type: "setting",
Href: "/repo/20783933/setting/builds_only_with_travis_yml",
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}

Expand Down Expand Up @@ -145,6 +148,7 @@ func TestSettingsService_Integration_UpdateByRepoIdAndSlug(t *testing.T) {
Type: "setting",
Href: "/repo/20783933/setting/builds_only_with_travis_yml",
Representation: "standard",
Permissions: Permissions{"read": true, "write": true},
},
}

Expand Down
5 changes: 5 additions & 0 deletions travis.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,9 @@ type Metadata struct {
Href string `json:"@href,omitempty"`
// The representation of data returned from the API, standard or minimal
Representation string `json:"@representation,omitempty"`
// The permissions of data returned from the API
Permissions Permissions `json:"@permissions,omitempty"`
}

// Permissions represents permissions of Travis CI API
type Permissions map[string]bool

0 comments on commit 4425a12

Please sign in to comment.