summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-03-16 17:00:00 -0400
committerCorey Hulen <corey@hulen.com>2017-03-16 14:00:00 -0700
commit9298315ce925afeb7824980e337633e3787643cd (patch)
tree2a15d3a62add27441e3c8d99a0b0cde566cded84
parent05e3dc9f2a352d053654fe0efa99de0a74fd566a (diff)
downloadchat-9298315ce925afeb7824980e337633e3787643cd.tar.gz
chat-9298315ce925afeb7824980e337633e3787643cd.tar.bz2
chat-9298315ce925afeb7824980e337633e3787643cd.zip
Fxing code coverage numbers + APIv4 tests with EE (#5789)
-rw-r--r--.gitignore1
-rw-r--r--Makefile99
-rw-r--r--api4/user_test.go5
-rw-r--r--app/saml.go2
4 files changed, 52 insertions, 55 deletions
diff --git a/.gitignore b/.gitignore
index f412f0342..b9775bad9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,6 +77,7 @@ enterprise
cover.out
ecover.out
+*.test
.agignore
.ctags
diff --git a/Makefile b/Makefile
index f4c19bd59..269734682 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,19 @@ DIST_PATH=$(DIST_ROOT)/mattermost
# Tests
TESTS=.
+# Packages lists
+TE_PACKAGES=$(shell go list ./... | grep -v vendor)
+TE_PACKAGES_COMMA=$(shell echo $(TE_PACKAGES) | tr ' ' ',')
+
+EE_PACKAGES=$(shell go list ./enterprise/... | grep -v vendor | tail -n +2)
+EE_PACKAGES_COMMA=$(shell echo $(EE_PACKAGES) | tr ' ' ',')
+
+ifeq ($(BUILD_ENTERPRISE_READY),true)
+ALL_PACKAGES_COMMA=$(TE_PACKAGES_COMMA),$(EE_PACKAGES_COMMA)
+else
+ALL_PACKAGES_COMMA=$(TE_PACKAGES_COMMA)
+endif
+
all: dist
dist: | check-style test package
@@ -196,65 +209,48 @@ check-server-style: govet
check-style: check-client-style check-server-style
-test-server: start-docker prepare-enterprise
- @echo Running server tests
+test-te: start-docker prepare-enterprise
+ @echo Testing TE
- rm -f cover.out
- echo "mode: count" > cover.out
-
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=1050s -covermode=count -coverprofile=capi.out ./api || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=800s -covermode=count -coverprofile=capi4.out ./api4 || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=60s -covermode=count -coverprofile=capp.out ./app || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=60s -covermode=count -coverprofile=cmodel.out ./model || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s -covermode=count -coverprofile=cstore.out ./store || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s -covermode=count -coverprofile=cutils.out ./utils || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s -covermode=count -coverprofile=cweb.out ./web || exit 1
-
- tail -n +2 capi.out >> cover.out
- tail -n +2 capi4.out >> cover.out
- tail -n +2 capp.out >> cover.out
- tail -n +2 cmodel.out >> cover.out
- tail -n +2 cstore.out >> cover.out
- tail -n +2 cutils.out >> cover.out
- tail -n +2 cweb.out >> cover.out
- rm -f capi.out capi4.out capp.out cmodel.out cstore.out cutils.out cweb.out
+ @echo "mode: count" > cover.out
+
+ @echo "Packages to test: "$(TE_PACKAGES)
+
+ @for package in $(TE_PACKAGES); do \
+ echo "Testing "$$package; \
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=2000s -covermode=count -coverprofile=cprofile.out -coverpkg=$(ALL_PACKAGES_COMMA) $$package || exit 1; \
+ if [ -f cprofile.out ]; then \
+ tail -n +2 cprofile.out >> cover.out; \
+ rm cprofile.out; \
+ fi; \
+ done
+
+test-ee: start-docker prepare-enterprise
+ @echo Testing EE
ifeq ($(BUILD_ENTERPRISE_READY),true)
- @echo Running Enterprise tests
+ @echo "Packages to test: "$(EE_PACKAGES)
+
+ for package in $(EE_PACKAGES); do \
+ echo "Testing "$$package; \
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -c $$package; \
+ if [ -f $$(basename $$package).test ]; then \
+ echo "Testing "$$package; \
+ ./$$(basename $$package).test -test.v -test.timeout=2000s -test.coverprofile=cprofile.out || exit 1; \
+ if [ -f cprofile.out ]; then \
+ tail -n +2 cprofile.out >> cover.out; \
+ rm cprofile.out; \
+ fi; \
+ rm -r $$(basename $$package).test; \
+ fi; \
+ done
- rm -f ecover.out
- echo "mode: count" > ecover.out
-
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/ldap && ./ldap.test -test.v -test.timeout=120s -test.coverprofile=cldap.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/compliance && ./compliance.test -test.v -test.timeout=120s -test.coverprofile=ccompliance.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/mfa && ./mfa.test -test.v -test.timeout=120s -test.coverprofile=cmfa.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/emoji && ./emoji.test -test.v -test.timeout=120s -test.coverprofile=cemoji.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/saml && ./saml.test -test.v -test.timeout=60s -test.coverprofile=csaml.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/cluster && ./cluster.test -test.v -test.timeout=60s -test.coverprofile=ccluster.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/metrics && ./metrics.test -test.v -test.timeout=60s -test.coverprofile=cmetrics.out || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/account_migration && ./account_migration.test -test.v -test.timeout=60s -test.coverprofile=caccount_migration.out || exit 1
-
- tail -n +2 cldap.out >> ecover.out
- tail -n +2 ccompliance.out >> ecover.out
- tail -n +2 cmfa.out >> ecover.out
- tail -n +2 cemoji.out >> ecover.out
- tail -n +2 csaml.out >> ecover.out
- tail -n +2 ccluster.out >> ecover.out
- tail -n +2 cmetrics.out >> ecover.out
- tail -n +2 caccount_migration.out >> ecover.out
- rm -f cldap.out ccompliance.out cmfa.out cemoji.out csaml.out ccluster.out cmetrics.out caccount_migration.out
- rm -r ldap.test
- rm -r compliance.test
- rm -r mfa.test
- rm -r emoji.test
- rm -r saml.test
- rm -r cluster.test
- rm -r metrics.test
- rm -r account_migration.test
rm -f config/*.crt
rm -f config/*.key
endif
+test-server: test-te test-ee
+
internal-test-web-client: start-docker prepare-enterprise
$(GO) run $(GOFLAGS) ./cmd/platform/*go test web_client_tests
@@ -458,6 +454,7 @@ clean: stop-docker
rm -f ecover.out
rm -f *.out
rm -f *.test
+ rm -f imports.go
nuke: clean clean-docker
@echo BOOM
diff --git a/api4/user_test.go b/api4/user_test.go
index 87e1dd64f..4805a1a51 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -11,7 +11,6 @@ import (
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
- "github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
)
@@ -804,7 +803,7 @@ func TestGetUsersNotInChannel(t *testing.T) {
CheckNoError(t, resp)
}
-func TestUpdateUserMfa(t *testing.T) {
+/*func TestUpdateUserMfa(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()
Client := th.Client
@@ -844,7 +843,7 @@ func TestUpdateUserMfa(t *testing.T) {
_, resp = Client.UpdateUserMfa(ruser.Id, "123456", false)
CheckNotImplementedStatus(t, resp)
-}
+}*/
func TestUpdateUserPassword(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
diff --git a/app/saml.go b/app/saml.go
index 444214302..92f0e1f0e 100644
--- a/app/saml.go
+++ b/app/saml.go
@@ -22,7 +22,7 @@ func GetSamlMetadata() (string, *model.AppError) {
}
if result, err := samlInterface.GetMetadata(); err != nil {
- return "", model.NewAppError("GetSamlMetadata", "api.admin.saml.metadata.app_error", nil, "err="+err.Message, http.StatusInternalServerError)
+ return "", model.NewAppError("GetSamlMetadata", "api.admin.saml.metadata.app_error", nil, "err="+err.Message, err.StatusCode)
} else {
return result, nil
}