Skip to content

Commit b8f2c8c

Browse files
committed
Use github actions
1 parent 5fddf59 commit b8f2c8c

10 files changed

+60
-601
lines changed

.github/workflows/lint-test.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint and Test
2+
3+
on: push
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Setup Go
12+
uses: actions/setup-go@v5
13+
with:
14+
go-version: "1.21.x"
15+
- name: Install dependencies
16+
run: go get .
17+
- name: Install linters
18+
run: |
19+
go install honnef.co/go/tools/cmd/staticcheck@latest
20+
go install mvdan.cc/unparam@latest
21+
- name: go vet
22+
run: go vet ${{ inputs.path }}
23+
- name: staticcheck
24+
run: staticcheck ${{ inputs.path }}
25+
- name: unparam
26+
run: unparam ${{ inputs.path }}
27+
28+
test:
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Setup Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: "1.21.x"
37+
- name: Install dependencies
38+
run: go get .
39+
- name: Run Tests
40+
run: go test -v -race ./...

.travis.yml

-9
This file was deleted.

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
[![Go Report Card](https://goreportcard.com/badge/plutov/paypal)](https://goreportcard.com/report/plutov/paypal)
2-
[![Build Status](https://travis-ci.org/plutov/paypal.svg?branch=master)](https://travis-ci.org/plutov/paypal)
3-
[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/plutov/paypal)
1+
[Docs](https://pkg.go.dev/github.com/plutov/paypal)
42

53
# Go client for PayPal REST API
64

client_test.go

-22
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ import (
1313
"github.com/stretchr/testify/assert"
1414
)
1515

16-
// testClientID, testSecret imported from order_test.go
17-
18-
// All test values are defined here
19-
// var testClientID = "AXy9orp-CDaHhBZ9C78QHW2BKZpACgroqo85_NIOa9mIfJ9QnSVKzY-X_rivR_fTUUr6aLjcJsj6sDur"
20-
// var testSecret = "EBoIiUSkCKeSk49hHSgTem1qnjzzJgRQHDEHvGpzlLEf_nIoJd91xu8rPOBDCdR_UYNKVxJE-UgS2iCw"
21-
var testUserID = "https://www.paypal.com/webapps/auth/identity/user/VBqgHcgZwb1PBs69ybjjXfIW86_Hr93aBvF_Rgbh2II"
22-
var testCardID = "CARD-54E6956910402550WKGRL6EA"
23-
24-
var testProductId = "" // will be fetched in func TestProduct(t *testing.T)
25-
var testBillingPlan = "" // will be fetched in func TestSubscriptionPlans(t *testing.T)
26-
2716
const alphabet = "abcedfghijklmnopqrstuvwxyz"
2817

2918
func RandomString(n int) string {
@@ -106,17 +95,6 @@ func TestClientMutex(t *testing.T) {
10695
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
10796
c.GetAccessToken(context.Background())
10897

109-
// Basic Testing of the private mutex field
110-
c.mu.Lock()
111-
if c.mu.TryLock() {
112-
t.Fatalf("TryLock succeeded with mutex locked")
113-
}
114-
c.mu.Unlock()
115-
if !c.mu.TryLock() {
116-
t.Fatalf("TryLock failed with mutex unlocked")
117-
}
118-
c.mu.Unlock() // undo changes from the previous TryLock
119-
12098
// Operational testing of the private mutex field
12199
n_iter := 2
122100

example_test.go

-59
This file was deleted.

products.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,27 @@ type (
3333
}
3434
)
3535

36-
func (self *Product) GetUpdatePatch() []Patch {
36+
func (p *Product) GetUpdatePatch() []Patch {
3737
return []Patch{
3838
{
3939
Operation: "replace",
4040
Path: "/description",
41-
Value: self.Description,
41+
Value: p.Description,
4242
},
4343
{
4444
Operation: "replace",
4545
Path: "/category",
46-
Value: self.Category,
46+
Value: p.Category,
4747
},
4848
{
4949
Operation: "replace",
5050
Path: "/image_url",
51-
Value: self.ImageUrl,
51+
Value: p.ImageUrl,
5252
},
5353
{
5454
Operation: "replace",
5555
Path: "/home_url",
56-
Value: self.HomeUrl,
56+
Value: p.HomeUrl,
5757
},
5858
}
5959
}

subscription.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type (
7777

7878
// https://developer.paypal.com/docs/api/subscriptions/v1/#definition-plan_override
7979
PlanOverride struct {
80-
BillingCycles []BillingCycleOverride `json:"billing_cycles,omitempty"`
80+
BillingCycles []BillingCycleOverride `json:"billing_cycles,omitempty"`
8181
PaymentPreferences *PaymentPreferencesOverride `json:"payment_preferences,omitempty"`
8282
Taxes *TaxesOverride `json:"taxes,omitempty"`
8383
}
@@ -104,12 +104,12 @@ type (
104104
}
105105
)
106106

107-
func (self *Subscription) GetUpdatePatch() []Patch {
107+
func (p *Subscription) GetUpdatePatch() []Patch {
108108
result := []Patch{
109109
{
110110
Operation: "replace",
111111
Path: "/billing_info/outstanding_balance",
112-
Value: self.BillingInfo.OutstandingBalance,
112+
Value: p.BillingInfo.OutstandingBalance,
113113
},
114114
}
115115
return result

subscription_plan.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -82,47 +82,47 @@ type (
8282
}
8383
)
8484

85-
func (self *SubscriptionPlan) GetUpdatePatch() []Patch {
85+
func (p *SubscriptionPlan) GetUpdatePatch() []Patch {
8686
result := []Patch{
8787
{
8888
Operation: "replace",
8989
Path: "/description",
90-
Value: self.Description,
90+
Value: p.Description,
9191
},
9292
}
9393

94-
if self.Taxes != nil {
94+
if p.Taxes != nil {
9595
result = append(result, Patch{
9696
Operation: "replace",
9797
Path: "/taxes/percentage",
98-
Value: self.Taxes.Percentage,
98+
Value: p.Taxes.Percentage,
9999
})
100100
}
101101

102-
if self.PaymentPreferences != nil {
103-
if self.PaymentPreferences.SetupFee != nil {
102+
if p.PaymentPreferences != nil {
103+
if p.PaymentPreferences.SetupFee != nil {
104104
result = append(result, Patch{
105105
Operation: "replace",
106106
Path: "/payment_preferences/setup_fee",
107-
Value: self.PaymentPreferences.SetupFee,
107+
Value: p.PaymentPreferences.SetupFee,
108108
},
109109
)
110110
}
111111

112112
result = append(result, []Patch{{
113113
Operation: "replace",
114114
Path: "/payment_preferences/auto_bill_outstanding",
115-
Value: self.PaymentPreferences.AutoBillOutstanding,
115+
Value: p.PaymentPreferences.AutoBillOutstanding,
116116
},
117117
{
118118
Operation: "replace",
119119
Path: "/payment_preferences/payment_failure_threshold",
120-
Value: self.PaymentPreferences.PaymentFailureThreshold,
120+
Value: p.PaymentPreferences.PaymentFailureThreshold,
121121
},
122122
{
123123
Operation: "replace",
124124
Path: "/payment_preferences/setup_fee_failure_action",
125-
Value: self.PaymentPreferences.SetupFeeFailureAction,
125+
Value: p.PaymentPreferences.SetupFeeFailureAction,
126126
}}...)
127127
}
128128

0 commit comments

Comments
 (0)