Skip to content

Commit

Permalink
Use github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
plutov committed May 27, 2024
1 parent 5fddf59 commit b8f2c8c
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 601 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint and Test

on: push

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
- name: Install dependencies
run: go get .
- name: Install linters
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
go install mvdan.cc/unparam@latest
- name: go vet
run: go vet ${{ inputs.path }}
- name: staticcheck
run: staticcheck ${{ inputs.path }}
- name: unparam
run: unparam ${{ inputs.path }}

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"
- name: Install dependencies
run: go get .
- name: Run Tests
run: go test -v -race ./...
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

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

# Go client for PayPal REST API

Expand Down
22 changes: 0 additions & 22 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ import (
"github.com/stretchr/testify/assert"
)

// testClientID, testSecret imported from order_test.go

// All test values are defined here
// var testClientID = "AXy9orp-CDaHhBZ9C78QHW2BKZpACgroqo85_NIOa9mIfJ9QnSVKzY-X_rivR_fTUUr6aLjcJsj6sDur"
// var testSecret = "EBoIiUSkCKeSk49hHSgTem1qnjzzJgRQHDEHvGpzlLEf_nIoJd91xu8rPOBDCdR_UYNKVxJE-UgS2iCw"
var testUserID = "https://www.paypal.com/webapps/auth/identity/user/VBqgHcgZwb1PBs69ybjjXfIW86_Hr93aBvF_Rgbh2II"
var testCardID = "CARD-54E6956910402550WKGRL6EA"

var testProductId = "" // will be fetched in func TestProduct(t *testing.T)
var testBillingPlan = "" // will be fetched in func TestSubscriptionPlans(t *testing.T)

const alphabet = "abcedfghijklmnopqrstuvwxyz"

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

// Basic Testing of the private mutex field
c.mu.Lock()
if c.mu.TryLock() {
t.Fatalf("TryLock succeeded with mutex locked")
}
c.mu.Unlock()
if !c.mu.TryLock() {
t.Fatalf("TryLock failed with mutex unlocked")
}
c.mu.Unlock() // undo changes from the previous TryLock

// Operational testing of the private mutex field
n_iter := 2

Expand Down
59 changes: 0 additions & 59 deletions example_test.go

This file was deleted.

10 changes: 5 additions & 5 deletions products.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ type (
}
)

func (self *Product) GetUpdatePatch() []Patch {
func (p *Product) GetUpdatePatch() []Patch {
return []Patch{
{
Operation: "replace",
Path: "/description",
Value: self.Description,
Value: p.Description,
},
{
Operation: "replace",
Path: "/category",
Value: self.Category,
Value: p.Category,
},
{
Operation: "replace",
Path: "/image_url",
Value: self.ImageUrl,
Value: p.ImageUrl,
},
{
Operation: "replace",
Path: "/home_url",
Value: self.HomeUrl,
Value: p.HomeUrl,
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type (

// https://developer.paypal.com/docs/api/subscriptions/v1/#definition-plan_override
PlanOverride struct {
BillingCycles []BillingCycleOverride `json:"billing_cycles,omitempty"`
BillingCycles []BillingCycleOverride `json:"billing_cycles,omitempty"`
PaymentPreferences *PaymentPreferencesOverride `json:"payment_preferences,omitempty"`
Taxes *TaxesOverride `json:"taxes,omitempty"`
}
Expand All @@ -104,12 +104,12 @@ type (
}
)

func (self *Subscription) GetUpdatePatch() []Patch {
func (p *Subscription) GetUpdatePatch() []Patch {
result := []Patch{
{
Operation: "replace",
Path: "/billing_info/outstanding_balance",
Value: self.BillingInfo.OutstandingBalance,
Value: p.BillingInfo.OutstandingBalance,
},
}
return result
Expand Down
20 changes: 10 additions & 10 deletions subscription_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,47 +82,47 @@ type (
}
)

func (self *SubscriptionPlan) GetUpdatePatch() []Patch {
func (p *SubscriptionPlan) GetUpdatePatch() []Patch {
result := []Patch{
{
Operation: "replace",
Path: "/description",
Value: self.Description,
Value: p.Description,
},
}

if self.Taxes != nil {
if p.Taxes != nil {
result = append(result, Patch{
Operation: "replace",
Path: "/taxes/percentage",
Value: self.Taxes.Percentage,
Value: p.Taxes.Percentage,
})
}

if self.PaymentPreferences != nil {
if self.PaymentPreferences.SetupFee != nil {
if p.PaymentPreferences != nil {
if p.PaymentPreferences.SetupFee != nil {
result = append(result, Patch{
Operation: "replace",
Path: "/payment_preferences/setup_fee",
Value: self.PaymentPreferences.SetupFee,
Value: p.PaymentPreferences.SetupFee,
},
)
}

result = append(result, []Patch{{
Operation: "replace",
Path: "/payment_preferences/auto_bill_outstanding",
Value: self.PaymentPreferences.AutoBillOutstanding,
Value: p.PaymentPreferences.AutoBillOutstanding,
},
{
Operation: "replace",
Path: "/payment_preferences/payment_failure_threshold",
Value: self.PaymentPreferences.PaymentFailureThreshold,
Value: p.PaymentPreferences.PaymentFailureThreshold,
},
{
Operation: "replace",
Path: "/payment_preferences/setup_fee_failure_action",
Value: self.PaymentPreferences.SetupFeeFailureAction,
Value: p.PaymentPreferences.SetupFeeFailureAction,
}}...)
}

Expand Down
Loading

0 comments on commit b8f2c8c

Please sign in to comment.