Skip to content

Commit 68ce353

Browse files
authored
Merge pull request #269 from moul/dev/moul/maintenance
2 parents 63b4aa5 + f7ed3a6 commit 68ce353

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: lint
2323
uses: golangci/[email protected]
2424
with:
25-
version: v1.28
25+
version: v1.38
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
2727
tests-on-windows:
2828
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors

AUTHORS

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/utils/emailvalidator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z
66

77
// ValidateEmail validates email.
88
func ValidateEmail(e string) bool {
9-
if len(e) < 3 && len(e) > 254 {
9+
if len(e) < 3 || len(e) > 254 {
1010
return false
1111
}
1212
return emailRegex.MatchString(e)

pkg/utils/emailvalidator_test.go

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
package utils
1+
package utils_test
22

33
import (
44
"testing"
5+
6+
"moul.io/sshportal/pkg/utils"
57
)
68

79
func TestValidateEmail(t *testing.T) {
8-
9-
goodEmail := "[email protected]"
10-
badEmail := "[email protected]"
11-
12-
got := ValidateEmail(goodEmail)
13-
if got == false {
14-
t.Errorf("got1= %v; want true", got)
10+
tests := []struct {
11+
input string
12+
expected bool
13+
}{
14+
{"[email protected]", true},
15+
{"[email protected]", true},
16+
{"b@2322.", false},
17+
{"", false},
18+
{"blah", false},
19+
{"blah.com", false},
1520
}
1621

17-
got2 := ValidateEmail(badEmail)
18-
if got2 == false {
19-
t.Errorf("got2= %v; want false", got2)
22+
for _, test := range tests {
23+
t.Run(test.input, func(t *testing.T) {
24+
got := utils.ValidateEmail(test.input)
25+
if got != test.expected {
26+
t.Errorf("expected %v, got %v", test.expected, got)
27+
}
28+
})
2029
}
21-
2230
}

rules.mk

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ ifeq ($(CI),true)
113113
@echo "mode: atomic" > /tmp/gocoverage
114114
@rm -f $(GOTESTJSON_FILE)
115115
@set -e; for dir in $(GOMOD_DIRS); do (set -e; (set -euf pipefail; \
116-
cd $$dir; \
117-
(($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json && touch [email protected]) | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \
116+
cd $$dir; \
117+
(($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json && touch [email protected]) | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \
118118
); \
119119
rm [email protected] 2>/dev/null || exit 1; \
120120
if [ -f /tmp/profile.out ]; then \
121-
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
122-
rm -f /tmp/profile.out; \
121+
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
122+
rm -f /tmp/profile.out; \
123123
fi)); done
124124
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
125125
else
@@ -128,8 +128,8 @@ else
128128
cd $$dir; \
129129
$(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race); \
130130
if [ -f /tmp/profile.out ]; then \
131-
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
132-
rm -f /tmp/profile.out; \
131+
cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \
132+
rm -f /tmp/profile.out; \
133133
fi); done
134134
@mv /tmp/gocoverage $(GOCOVERAGE_FILE)
135135
endif
@@ -243,8 +243,8 @@ npm.publish:
243243
@echo -n "Do you want to npm publish? [y/N] " && read ans && \
244244
@if [ $${ans:-N} = y ]; then \
245245
set -e; for dir in $(NPM_PACKAGES); do ( set -xe; \
246-
cd $$dir; \
247-
npm publish --access=public; \
246+
cd $$dir; \
247+
npm publish --access=public; \
248248
); done; \
249249
fi
250250
RELEASE_STEPS += npm.publish
@@ -254,7 +254,7 @@ endif
254254
## Docker
255255
##
256256

257-
docker_build = docker build \
257+
docker_build = docker build \
258258
--build-arg VCS_REF=`git rev-parse --short HEAD` \
259259
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
260260
--build-arg VERSION=`git describe --tags --always` \

0 commit comments

Comments
 (0)