-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
293ebd4
commit a60c0bc
Showing
14 changed files
with
373 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package test | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/checkout/checkout-sdk-go/configuration" | ||
"github.com/checkout/checkout-sdk-go/mocks" | ||
) | ||
|
||
func TestShouldCreateConfiguration(t *testing.T) { | ||
credentials := new(mocks.CredentialsMock) | ||
environment := configuration.Production() | ||
subdomain := configuration.NewEnvironmentSubdomain(environment, "123dmain") | ||
subdomainBad := configuration.NewEnvironmentSubdomain(environment, "baddomain") | ||
|
||
cases := []struct { | ||
name string | ||
configuration *configuration.Configuration | ||
checker func(*configuration.Configuration, error) | ||
}{ | ||
{ | ||
name: "should create a configuration object", | ||
configuration: configuration.NewConfiguration(credentials, environment, &http.Client{}, nil), | ||
checker: func(configuration *configuration.Configuration, err error) { | ||
assert.NotNil(t, configuration) | ||
}, | ||
}, | ||
{ | ||
name: "should create a configuration object with a valid subdomain", | ||
configuration: configuration.NewConfigurationWithSubdomain(credentials, environment, subdomain, &http.Client{}, nil), | ||
checker: func(configuration *configuration.Configuration, err error) { | ||
assert.NotNil(t, configuration) | ||
assert.Equal(t, "https://123dmain.api.checkout.com", configuration.EnvironmentSubdomain.ApiUrl) | ||
}, | ||
}, | ||
{ | ||
name: "should create a configuration object with a invalid subdomain", | ||
configuration: configuration.NewConfigurationWithSubdomain(credentials, environment, subdomainBad, &http.Client{}, nil), | ||
checker: func(configuration *configuration.Configuration, err error) { | ||
assert.NotNil(t, configuration) | ||
assert.Equal(t, "https://api.checkout.com", configuration.EnvironmentSubdomain.ApiUrl) | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tc.checker(tc.configuration, nil) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/checkout/checkout-sdk-go" | ||
"github.com/checkout/checkout-sdk-go/configuration" | ||
"github.com/checkout/checkout-sdk-go/nas" | ||
) | ||
|
||
func TestDefaultCheckoutSdks(t *testing.T) { | ||
var defaultApi, _ = checkout.Builder(). | ||
StaticKeys(). | ||
WithSecretKey(os.Getenv("CHECKOUT_DEFAULT_SECRET_KEY")). | ||
WithPublicKey(os.Getenv("CHECKOUT_DEFAULT_PUBLIC_KEY")). | ||
WithEnvironment(configuration.Sandbox()). | ||
Build() | ||
|
||
var defaultApiSubdomain, _ = checkout.Builder(). | ||
StaticKeys(). | ||
WithSecretKey(os.Getenv("CHECKOUT_DEFAULT_SECRET_KEY")). | ||
WithPublicKey(os.Getenv("CHECKOUT_DEFAULT_PUBLIC_KEY")). | ||
WithEnvironment(configuration.Sandbox()). | ||
WithEnvironmentSubdomain("123dmain"). | ||
Build() | ||
|
||
var defaultApiBad, _ = checkout.Builder(). | ||
StaticKeys(). | ||
WithSecretKey("error"). | ||
WithPublicKey("error"). | ||
WithEnvironment(configuration.Sandbox()). | ||
Build() | ||
|
||
cases := []struct { | ||
name string | ||
defaultApi *nas.Api | ||
checker func(*nas.Api, error) | ||
}{ | ||
{ | ||
name: "should create a default checkout sdk api object", | ||
defaultApi: defaultApi, | ||
checker: func(token *nas.Api, err error) { | ||
assert.NotNil(t, defaultApi) | ||
}, | ||
}, | ||
{ | ||
name: "should create a default checkout sdk api object with valid subdomain", | ||
defaultApi: defaultApiSubdomain, | ||
checker: func(token *nas.Api, err error) { | ||
assert.NotNil(t, defaultApiSubdomain) | ||
}, | ||
}, | ||
{ | ||
name: "should fail a default checkout sdk api object", | ||
defaultApi: defaultApiBad, | ||
checker: func(token *nas.Api, err error) { | ||
assert.Nil(t, defaultApiBad) | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tc.checker(tc.defaultApi, nil) | ||
}) | ||
} | ||
|
||
} |
Oops, something went wrong.