Skip to content

Instantly share code, notes, and snippets.

@laynax
Created December 2, 2018 08:36
Show Gist options
  • Save laynax/3e8dfba6bfc2defddf1f32209aeaa85a to your computer and use it in GitHub Desktop.
Save laynax/3e8dfba6bfc2defddf1f32209aeaa85a to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"testing"
)
type Card struct {
Card string
Pin int
Cvv2 int
}
var input1 = `{
"card": "60379972576170363",
"pin": 123456,
"cvv2": 123
}`
var input2 = `{
"card": "60379972576170363",
"cvv2": 123
}`
func TestInpu1(t *testing.T) {
var val Card
if err := json.Unmarshal([]byte(input1), &val); err != nil {
t.Error(err.Error())
}
if val.Pin == 0 {
t.Error("pin could not be empty")
}
}
func TestInput2(t *testing.T) {
var val Card
if err := json.Unmarshal([]byte(input2), &val); err != nil {
t.Error(err.Error())
}
if val.Pin == 0 {
t.Error("pin could not be empty")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment