diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index aaa6fca..e91bb89 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -17,6 +17,6 @@ jobs: with: go-version: "1.16" - name: Run coverage - run: go test -race -coverprofile=coverage.txt -covermode=atomic + run: go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic - name: Upload coverage to Codecov run: bash <(curl -s https://codecov.io/bash) diff --git a/.gitignore b/.gitignore index 1e71714..e0921c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .idea/* .vscode/* -.DS_Store \ No newline at end of file +.DS_Store +cryptor/*.txt +fileutil/*.txt +cryptor/*.pem \ No newline at end of file diff --git a/fileutil/file_test.go b/fileutil/file_test.go index e7f2bb1..7941434 100644 --- a/fileutil/file_test.go +++ b/fileutil/file_test.go @@ -87,11 +87,11 @@ func TestCopyFile(t *testing.T) { } func TestListFileNames(t *testing.T) { - filesInCurrentPath, err := ListFileNames("./") + filesInCurrentPath, err := ListFileNames("../datetime/") if err != nil { t.FailNow() } - expected := []string{"file.go", "file_test.go"} + expected := []string{"datetime.go", "datetime_test.go"} if !reflect.DeepEqual(filesInCurrentPath, expected) { utils.LogFailedTestInfo(t, "ToChar", "./", expected, filesInCurrentPath) t.FailNow() diff --git a/validator/validator.go b/validator/validator.go index 2f2e13b..c8b1da2 100644 --- a/validator/validator.go +++ b/validator/validator.go @@ -26,11 +26,7 @@ func IsNumberStr(s string) bool { // IsFloatStr check if the string can convert to a float. func IsFloatStr(s string) bool { _, e := strconv.ParseFloat(s, 64) - - if e != nil { - return false - } - return true + return e == nil } // IsIntStr check if the string can convert to a integer. @@ -42,10 +38,7 @@ func IsIntStr(s string) bool { // IsIp check if the string is a ip address. func IsIp(ipstr string) bool { ip := net.ParseIP(ipstr) - if ip == nil { - return false - } - return true + return ip != nil } // IsIpV4 check if the string is a ipv4 address. diff --git a/validator/validator_test.go b/validator/validator_test.go index cfbd896..cb9ea7d 100644 --- a/validator/validator_test.go +++ b/validator/validator_test.go @@ -190,7 +190,7 @@ func isCreditCard(t *testing.T, source string, expected bool) { } func TestIsBase64(t *testing.T) { - isBase64(t, "aGVsbG8", true) + isBase64(t, "aGVsbG8=", true) isBase64(t, "123456", false) }