Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-04-13 18:40:33 +0300
committerNick Thomas <nick@gitlab.com>2018-04-13 18:40:33 +0300
commit3ef85e8d058598144c72a31ee76431cc5a0bb457 (patch)
tree08fe881cc3d12dee4cd11fc76066274fd9c23a47
parent82347898105a7d99876a21482e6999ad05287c9c (diff)
parenta07231a547203f5856e18e9bf3d5308637fa07ab (diff)
Merge branch 'require-error' into 'master'
Use require.NoError instead of assert.NoError See merge request gitlab-org/gitlab-pages!87
-rw-r--r--acceptance_test.go4
-rw-r--r--internal/artifact/artifact_test.go3
-rw-r--r--internal/jail/jail_test.go36
3 files changed, 22 insertions, 21 deletions
diff --git a/acceptance_test.go b/acceptance_test.go
index 1b250050..78413205 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -68,7 +68,7 @@ func TestUnknownProjectReturnsNotFound(t *testing.T) {
defer teardown()
rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "/nonexistent/")
- assert.NoError(t, err)
+ require.NoError(t, err)
defer rsp.Body.Close()
assert.Equal(t, http.StatusNotFound, rsp.StatusCode)
}
@@ -79,7 +79,7 @@ func TestGroupDomainReturns200(t *testing.T) {
defer teardown()
rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "/")
- assert.NoError(t, err)
+ require.NoError(t, err)
defer rsp.Body.Close()
assert.Equal(t, http.StatusOK, rsp.StatusCode)
}
diff --git a/internal/artifact/artifact_test.go b/internal/artifact/artifact_test.go
index 62962513..73dd4bdc 100644
--- a/internal/artifact/artifact_test.go
+++ b/internal/artifact/artifact_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-pages/internal/artifact"
)
@@ -78,7 +79,7 @@ func TestTryMakeRequest(t *testing.T) {
t.Run(c.Description, func(t *testing.T) {
result := httptest.NewRecorder()
reqURL, err := url.Parse("/-/subgroup/project/-/jobs/1/artifacts" + c.Path)
- assert.NoError(t, err)
+ require.NoError(t, err)
r := &http.Request{URL: reqURL}
art := artifact.New(testServer.URL, 1, "gitlab-example.io")
diff --git a/internal/jail/jail_test.go b/internal/jail/jail_test.go
index 2095000e..2295b730 100644
--- a/internal/jail/jail_test.go
+++ b/internal/jail/jail_test.go
@@ -50,11 +50,11 @@ func TestJailBuild(t *testing.T) {
assert.Error(err, "Jail path should not exist before Jail.Build()")
err = cage.Build()
- assert.NoError(err)
+ require.NoError(t, err)
defer cage.Dispose()
_, err = os.Stat(cage.Path())
- assert.NoError(err, "Jail path should exist after Jail.Build()")
+ require.NoError(t, err, "Jail path should exist after Jail.Build()")
}
func TestJailDispose(t *testing.T) {
@@ -64,10 +64,10 @@ func TestJailDispose(t *testing.T) {
cage := jail.New(jailPath, 0755)
err := cage.Build()
- assert.NoError(err)
+ require.NoError(t, err)
err = cage.Dispose()
- assert.NoError(err)
+ require.NoError(t, err)
_, err = os.Stat(cage.Path())
assert.Error(err, "Jail path should not exist after Jail.Dispose()")
@@ -83,7 +83,7 @@ func TestJailDisposeDoNotFailOnMissingPath(t *testing.T) {
assert.Error(err, "Jail path should not exist")
err = cage.Dispose()
- assert.NoError(err)
+ require.NoError(t, err)
}
func TestJailWithFiles(t *testing.T) {
@@ -134,16 +134,16 @@ func TestJailWithFiles(t *testing.T) {
if test.error {
assert.Error(err)
} else {
- assert.NoError(err)
+ require.NoError(t, err)
for _, dir := range test.directories {
_, err := os.Stat(path.Join(cage.Path(), dir))
- assert.NoError(err, "jailed dir should exist")
+ require.NoError(t, err, "jailed dir should exist")
}
for _, file := range test.files {
_, err := os.Stat(path.Join(cage.Path(), file))
- assert.NoError(err, "Jailed file should exist")
+ require.NoError(t, err, "Jailed file should exist")
}
}
})
@@ -168,23 +168,23 @@ func TestJailCopyTo(t *testing.T) {
jailedFilePath := cage.ExternalPath(path.Base(filePath))
err = cage.CopyTo(path.Base(filePath), filePath)
- assert.NoError(err)
+ require.NoError(t, err)
err = cage.Build()
defer cage.Dispose()
- assert.NoError(err)
+ require.NoError(t, err)
jailedFI, err := os.Stat(jailedFilePath)
- assert.NoError(err)
+ require.NoError(t, err)
fi, err := os.Stat(filePath)
- assert.NoError(err)
+ require.NoError(t, err)
assert.Equal(fi.Mode(), jailedFI.Mode(), "jailed file should preserve file mode")
assert.Equal(fi.Size(), jailedFI.Size(), "jailed file should have same size of original file")
jailedContent, err := ioutil.ReadFile(jailedFilePath)
- assert.NoError(err)
+ require.NoError(t, err)
assert.Equal(content, string(jailedContent), "jailed file should preserve file content")
}
@@ -211,26 +211,26 @@ func TestJailLazyUnbind(t *testing.T) {
cage.Bind("/my-bind", toBind)
err = cage.Build()
- assert.NoError(err, "jail build failed")
+ require.NoError(t, err, "jail build failed")
bindedTmpFilePath := cage.ExternalPath("/my-bind/a-file")
f, err := os.Open(bindedTmpFilePath)
- assert.NoError(err, "temporary file not binded")
+ require.NoError(t, err, "temporary file not binded")
require.NotNil(t, f)
err = cage.LazyUnbind()
- assert.NoError(err, "lazy unbind failed")
+ require.NoError(t, err, "lazy unbind failed")
f.Close()
_, err = os.Stat(bindedTmpFilePath)
assert.Error(err, "lazy unbind should remove mount-point after file close")
err = cage.Dispose()
- assert.NoError(err, "dispose failed")
+ require.NoError(t, err, "dispose failed")
_, err = os.Stat(cage.Path())
assert.Error(err, "Jail path should not exist after Jail.Dispose()")
_, err = os.Stat(tmpFilePath)
- assert.NoError(err, "disposing a jail should not delete files under binded directories")
+ require.NoError(t, err, "disposing a jail should not delete files under binded directories")
}