paypale/auth_test.go

55 lines
1.2 KiB
Go
Raw Normal View History

2015-10-15 10:47:36 +02:00
package paypalsdk
import (
2015-10-30 08:02:32 +01:00
"testing"
2015-10-15 10:47:36 +02:00
)
2015-10-30 08:02:32 +01:00
func TestGetAccessToken(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
2015-11-20 07:38:40 +01:00
c.GetAccessToken()
2015-10-16 12:00:57 +02:00
}
func TestGetAuthorization(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
c.GetAccessToken()
_, err := c.GetAuthorization("123")
if err == nil {
t.Errorf("Error must be returned for invalid Auth ID")
}
}
func TestCaptureAuthorization(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
c.GetAccessToken()
_, err := c.CaptureAuthorization("123", &Amount{Total: "200", Currency: "USD"}, true)
if err == nil {
t.Errorf("Error must be returned for invalid Auth ID")
}
}
func TestVoidAuthorization(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
c.GetAccessToken()
_, err := c.VoidAuthorization("123")
if err == nil {
t.Errorf("Error must be returned for invalid Auth ID")
}
}
func TestReauthorizeAuthorization(t *testing.T) {
c, _ := NewClient("clid", "secret", APIBaseSandBox)
c.GetAccessToken()
_, err := c.ReauthorizeAuthorization("123", &Amount{Total: "200", Currency: "USD"})
if err == nil {
t.Errorf("Error must be returned for invalid Auth ID")
}
}