-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create client_test and fix tokenization_test (#2)
* Improving credit card tokenize tests * Adjust with env variables * Rollback vars * Create client_test * Remove .env Co-authored-by: Walter Junior <[email protected]>
- Loading branch information
1 parent
29c911b
commit 002bacb
Showing
2 changed files
with
85 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/vasconcelosvcd/go-cielo" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func getNewClient(success bool, t *testing.T) (*cielo.Client, error) { | ||
t.Helper() | ||
if success { | ||
return cielo.NewClient(os.Getenv("MERCHANT_ID"), os.Getenv("MERCHANT_KEY"), cielo.SandboxEnvironment) | ||
} | ||
return cielo.NewClient("", "", cielo.SandboxEnvironment) | ||
} | ||
|
||
func Test_NewClient(t *testing.T) { | ||
t.Run("SUCCESS", func(t *testing.T) { | ||
client, err := getNewClient(true, t) | ||
if err != nil { | ||
t.Fatalf("Errors was not expected. Err: %v", err.Error()) | ||
} | ||
|
||
expected := "*cielo.Client" | ||
got := fmt.Sprintf("%T", client) | ||
|
||
if got != expected { | ||
t.Errorf("Was expected '%v', but got '%v'", expected, got) | ||
} | ||
}) | ||
|
||
t.Run("FAIL", func(t *testing.T) { | ||
client, err := getNewClient(false, t) | ||
if err == nil { | ||
t.Error("Errors was expected.") | ||
} | ||
|
||
if client != nil { | ||
t.Error("Client must be 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