move PIN test to the common package
This commit is contained in:
parent
48d63fb43f
commit
5ca6a74274
56
common/pin_test.go
Normal file
56
common/pin_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package common
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsValidPIN(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pin string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "Valid PIN with 4 digits",
|
||||
pin: "1234",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Valid PIN with leading zeros",
|
||||
pin: "0001",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with less than 4 digits",
|
||||
pin: "123",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with more than 4 digits",
|
||||
pin: "12345",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with letters",
|
||||
pin: "abcd",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with special characters",
|
||||
pin: "12@#",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Empty PIN",
|
||||
pin: "",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual := IsValidPIN(tt.pin)
|
||||
if actual != tt.expected {
|
||||
t.Errorf("IsValidPIN(%q) = %v; expected %v", tt.pin, actual, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1499,59 +1499,6 @@ func TestQuit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidPIN(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pin string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "Valid PIN with 4 digits",
|
||||
pin: "1234",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Valid PIN with leading zeros",
|
||||
pin: "0001",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with less than 4 digits",
|
||||
pin: "123",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with more than 4 digits",
|
||||
pin: "12345",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with letters",
|
||||
pin: "abcd",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Invalid PIN with special characters",
|
||||
pin: "12@#",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "Empty PIN",
|
||||
pin: "",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual := common.IsValidPIN(tt.pin)
|
||||
if actual != tt.expected {
|
||||
t.Errorf("IsValidPIN(%q) = %v; expected %v", tt.pin, actual, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateAmount(t *testing.T) {
|
||||
fm, err := NewFlagManager(flagsPath)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user