Skip to content

Commit

Permalink
Begin expanding test coverage for provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mpchadwick committed Nov 17, 2020
1 parent 6ed9eda commit db9c9f9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dbanon

import (
"github.com/sirupsen/logrus/hooks/test"
"regexp"
"testing"
)

Expand Down Expand Up @@ -50,4 +51,29 @@ func TestGet(t *testing.T) {
if hook.LastEntry().Message != "Could not identify arguments for Slug" {
t.Errorf("Malformed arguments not handled correctly")
}

// https://github.com/dmgk/faker/blob/v1.2.3/name_test.go#L10
r5 := provider.Get("firstname")
rx1 := `[A-Z][a-z']+`
if m, _ := regexp.MatchString(rx1, r5); !m {
t.Errorf("Expected %v to match %v", r5, rx1)
}

r6 := provider.Get("lastname")
if m, _ := regexp.MatchString(rx1, r6); !m {
t.Errorf("Expected %v to match %v", r6, rx1)
}

rx2 := `[A-Z][a-z']+ [A-Z][a-z']+`
r7 := provider.Get("fullname")
if m, _ := regexp.MatchString(rx2, r7); !m {
t.Errorf("Expected %v to match %v", r7, rx2)
}

// https://github.com/dmgk/faker/blob/master/internet_test.go#L25
rx3 := `\w+`
r8 := provider.Get("username")
if m, _ := regexp.MatchString(rx3, r8); !m {
t.Errorf("Expected %v to match %v", r8, rx3)
}
}

0 comments on commit db9c9f9

Please sign in to comment.