Skip to content

Commit 4a920e3

Browse files
committed
chore(builder): use testify replace assert
1 parent b8ddcd9 commit 4a920e3

13 files changed

Lines changed: 138 additions & 207 deletions

File tree

go.mod

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
module github.com/drycc/builder
22

3-
go 1.17
3+
go 1.18
44

55
require (
6-
github.com/arschles/assert v1.0.1-0.20191213221312-71f210f9375a
7-
github.com/aws/aws-sdk-go v1.43.44
8-
github.com/distribution/distribution/v3 v3.0.0-20220422123413-27b556324553
9-
github.com/drycc/controller-sdk-go v0.0.0-20220414163543-b9fc87956088
10-
github.com/drycc/pkg v0.0.0-20220414163413-88896c2e0ef0
6+
github.com/aws/aws-sdk-go v1.44.66
7+
github.com/distribution/distribution/v3 v3.0.0-20220729163034-26163d82560f
8+
github.com/drycc/controller-sdk-go v0.0.0-20220801120356-de65d8cb5598
9+
github.com/drycc/pkg v0.0.0-20220801143647-f56f4c2f5ad1
1110
github.com/kelseyhightower/envconfig v1.4.0
1211
github.com/pborman/uuid v1.2.1
12+
github.com/stretchr/testify v1.8.0
1313
github.com/urfave/cli/v2 v2.4.4
1414
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
15-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
15+
gopkg.in/yaml.v3 v3.0.1
1616
k8s.io/api v0.23.6
1717
k8s.io/apimachinery v0.23.6
1818
k8s.io/client-go v0.23.6
@@ -22,6 +22,7 @@ require (
2222
github.com/PuerkitoBio/purell v1.1.1 // indirect
2323
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
2424
github.com/beorn7/perks v1.0.1 // indirect
25+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
2526
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
2627
github.com/davecgh/go-spew v1.1.1 // indirect
2728
github.com/docker/go-metrics v0.0.1 // indirect
@@ -39,15 +40,16 @@ require (
3940
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
4041
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4142
github.com/modern-go/reflect2 v1.0.2 // indirect
42-
github.com/prometheus/client_golang v1.1.0 // indirect
43-
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
44-
github.com/prometheus/common v0.6.0 // indirect
45-
github.com/prometheus/procfs v0.0.3 // indirect
43+
github.com/pmezard/go-difflib v1.0.0 // indirect
44+
github.com/prometheus/client_golang v1.12.1 // indirect
45+
github.com/prometheus/client_model v0.2.0 // indirect
46+
github.com/prometheus/common v0.32.1 // indirect
47+
github.com/prometheus/procfs v0.7.3 // indirect
4648
github.com/russross/blackfriday/v2 v2.1.0 // indirect
4749
github.com/sirupsen/logrus v1.8.1 // indirect
4850
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
4951
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
50-
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
52+
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
5153
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
5254
golang.org/x/text v0.3.7 // indirect
5355
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect

go.sum

Lines changed: 56 additions & 125 deletions
Large diffs are not rendered by default.

pkg/cleaner/cleaner_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"strings"
77
"testing"
88

9-
"github.com/arschles/assert"
10-
"k8s.io/api/core/v1"
9+
"github.com/stretchr/testify/assert"
10+
v1 "k8s.io/api/core/v1"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
)
1313

@@ -28,14 +28,14 @@ func TestDirHasGitSuffix(t *testing.T) {
2828

2929
func TestLocalDirs(t *testing.T) {
3030
wd, err := os.Getwd()
31-
assert.NoErr(t, err)
31+
assert.Equal(t, err, nil)
3232
pkgDir, err := filepath.Abs(wd + "/..")
33-
assert.NoErr(t, err)
33+
assert.Equal(t, err, nil)
3434
lDirs, err := localDirs(pkgDir, func(dir string) bool {
3535
// no directories with any dots in them
3636
return len(strings.Split(dir, ".")) == 1
3737
})
38-
assert.NoErr(t, err)
38+
assert.Equal(t, err, nil)
3939

4040
expectedPackages := map[string]int{
4141
"cleaner": 1,

pkg/conf/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"path/filepath"
77
"testing"
88

9-
"github.com/arschles/assert"
109
"github.com/drycc/builder/pkg/sys"
10+
"github.com/stretchr/testify/assert"
1111
)
1212

1313
func TestGetStorageParams(t *testing.T) {
@@ -51,7 +51,7 @@ func TestGetControllerClient(t *testing.T) {
5151
}
5252

5353
key, err := GetBuilderKey()
54-
assert.NoErr(t, err)
54+
assert.Equal(t, err, nil)
5555
assert.Equal(t, key, string(data), "data")
5656
}
5757

pkg/controller/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010

1111
builderconf "github.com/drycc/builder/pkg/conf"
12+
"github.com/stretchr/testify/assert"
1213

13-
"github.com/arschles/assert"
1414
drycc "github.com/drycc/controller-sdk-go"
1515
)
1616

@@ -35,7 +35,7 @@ func TestNew(t *testing.T) {
3535
host := "127.0.0.1"
3636
port := "80"
3737
cli, err := New(host, port)
38-
assert.NoErr(t, err)
38+
assert.Equal(t, err, nil)
3939
assert.Equal(t, cli.ControllerURL.String(), fmt.Sprintf("http://%s:%s/", host, port), "data")
4040
assert.Equal(t, cli.HooksToken, string(data), "data")
4141
assert.Equal(t, cli.UserAgent, "drycc-builder", "user-agent")

pkg/git/git_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/arschles/assert"
11+
"github.com/stretchr/testify/assert"
1212
)
1313

1414
func TestCreatePreReceiveHook(t *testing.T) {
1515
const gitHome = "TestGitHome"
1616
gopath := os.Getenv("GOPATH")
1717
repoPath := filepath.Join(gopath, "src", "github.com", "drycc", "builder", "testdata")
18-
assert.NoErr(t, createPreReceiveHook(gitHome, repoPath))
18+
assert.Equal(t, createPreReceiveHook(gitHome, repoPath), nil)
1919
hookBytes, err := ioutil.ReadFile(filepath.Join(repoPath, "hooks", "pre-receive"))
20-
assert.NoErr(t, err)
20+
assert.Equal(t, err, nil)
2121
hookStr := string(hookBytes)
2222
gitHomeIdx := strings.Index(hookStr, fmt.Sprintf("GIT_HOME=%s", gitHome))
2323
assert.False(t, gitHomeIdx == -1, "GIT_HOME was not found")

pkg/gitreceive/build_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ import (
99
"path/filepath"
1010
"testing"
1111

12-
"github.com/arschles/assert"
13-
1412
//"github.com/distribution/distribution/v3/context"
1513
"github.com/distribution/distribution/v3/registry/storage/driver/factory"
1614
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
1715
builderconf "github.com/drycc/builder/pkg/conf"
1816
"github.com/drycc/builder/pkg/sys"
1917
"github.com/drycc/controller-sdk-go/api"
2018
"github.com/drycc/pkg/log"
19+
"github.com/stretchr/testify/assert"
2120
"gopkg.in/yaml.v3"
2221
)
2322

@@ -120,7 +119,7 @@ func TestGetProcfileFromRepoSuccess(t *testing.T) {
120119
procType, err := getProcfile(tmpDir, getStack(tmpDir, config))
121120
actualData := api.ProcessType{}
122121
yaml.Unmarshal(data, &actualData)
123-
assert.NoErr(t, err)
122+
assert.Equal(t, err, nil)
124123
assert.Equal(t, procType, actualData, "data")
125124
}
126125

@@ -158,7 +157,7 @@ func TestGetProcfileFromServerSuccess(t *testing.T) {
158157
_, err := getProcfile("", getStack(tmpDir, config))
159158
actualData := api.ProcessType{}
160159
yaml.Unmarshal(data, &actualData)
161-
assert.Err(t, err, fmt.Errorf("no Procfile can be matched in (%s)", ""))
160+
assert.Error(t, err, fmt.Errorf("no Procfile can be matched in (%s)", ""))
162161
}
163162

164163
func TestGetProcfileFromServerFailure(t *testing.T) {
@@ -168,7 +167,7 @@ func TestGetProcfileFromServerFailure(t *testing.T) {
168167
"DRYCC_STACK": "buildpack",
169168
}
170169
_, err := getProcfile("", getStack(tmpDir, config))
171-
assert.Err(t, err, fmt.Errorf("no Procfile can be matched in (%s)", ""))
170+
assert.Error(t, err, fmt.Errorf("no Procfile can be matched in (%s)", ""))
172171
assert.True(t, err != nil, "no error received when there should have been")
173172
}
174173

@@ -244,5 +243,5 @@ func TestBuildBuilderPodNodeSelector(t *testing.T) {
244243
}
245244

246245
_, err := buildBuilderPodNodeSelector("invalidformat")
247-
assert.ExistsErr(t, err, "invalid format")
246+
assert.NotEqual(t, err, nil, "invalid format")
248247
}

pkg/gitreceive/imagebuilder_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"errors"
55
"testing"
66

7-
"github.com/arschles/assert"
87
"github.com/drycc/builder/pkg/sys"
8+
"github.com/stretchr/testify/assert"
99
)
1010

1111
func TestGetImagebuilderEnvOffclusterErr(t *testing.T) {
@@ -21,10 +21,10 @@ func TestGetImagebuilderEnvOffclusterErr(t *testing.T) {
2121
"DRYCC_REGISTRY_LOCATION": "off-cluster",
2222
}
2323
_, err := getImagebuilderEnv(&image, config, env)
24-
assert.Err(t, err, errors.New("the environment variable DRYCC_REGISTRY_HOST is required"))
24+
assert.Error(t, err, errors.New("the environment variable DRYCC_REGISTRY_HOST is required"))
2525
env.Envs["DRYCC_REGISTRY_HOST"] = "drycc-registry.drycc.svc.cluster.local"
2626
_, err = getImagebuilderEnv(&image, config, env)
27-
assert.Err(t, err, errors.New("the environment variable DRYCC_REGISTRY_ORGANIZATION is required"))
27+
assert.Error(t, err, errors.New("the environment variable DRYCC_REGISTRY_ORGANIZATION is required"))
2828
}
2929

3030
func TestGetImagebuilderEnvOffclusterSuccess(t *testing.T) {
@@ -52,7 +52,7 @@ func TestGetImagebuilderEnvOffclusterSuccess(t *testing.T) {
5252

5353
image := "test-image"
5454
imagebuilderEnv, err := getImagebuilderEnv(&image, config, env)
55-
assert.NoErr(t, err)
55+
assert.Equal(t, err, nil)
5656
assert.Equal(t, expectedData, imagebuilderEnv, "registry details")
5757

5858
assert.Equal(t, expectedImage, image, "image")
@@ -84,7 +84,7 @@ func TestGetImagebuilderEnvOnclusterSuccess(t *testing.T) {
8484

8585
image := "python-getting-started-web:v1.2.1"
8686
imagebuilderEnv, err := getImagebuilderEnv(&image, config, env)
87-
assert.NoErr(t, err)
87+
assert.Equal(t, err, nil)
8888
assert.Equal(t, expectedData, imagebuilderEnv, "registry details")
8989

9090
assert.Equal(t, expectedImage, image, "image")

pkg/gitreceive/k8s_util_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"strings"
77
"testing"
88

9-
"github.com/arschles/assert"
109
"github.com/drycc/builder/pkg/k8s"
10+
"github.com/stretchr/testify/assert"
1111
batchv1 "k8s.io/api/batch/v1"
1212
corev1 "k8s.io/api/core/v1"
1313
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -150,7 +150,7 @@ func TestCreateAppEnvConfigSecretErr(t *testing.T) {
150150
},
151151
}
152152
err := createAppEnvConfigSecret(secretsClient, "test", nil)
153-
assert.Err(t, err, expectedErr)
153+
assert.Error(t, err, expectedErr)
154154
}
155155

156156
func TestCreateAppEnvConfigSecretSuccess(t *testing.T) {
@@ -160,7 +160,7 @@ func TestCreateAppEnvConfigSecretSuccess(t *testing.T) {
160160
},
161161
}
162162
err := createAppEnvConfigSecret(secretsClient, "test", nil)
163-
assert.NoErr(t, err)
163+
assert.Equal(t, err, nil)
164164
}
165165

166166
func TestCreateAppEnvConfigSecretAlreadyExists(t *testing.T) {
@@ -174,5 +174,5 @@ func TestCreateAppEnvConfigSecretAlreadyExists(t *testing.T) {
174174
},
175175
}
176176
err := createAppEnvConfigSecret(secretsClient, "test", nil)
177-
assert.NoErr(t, err)
177+
assert.Equal(t, err, nil)
178178
}

pkg/healthsrv/healthz_handler_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313

1414
//"github.com/distribution/distribution/v3/context"
1515

16-
"github.com/arschles/assert"
1716
"github.com/drycc/builder/pkg/sshd"
1817
drycc "github.com/drycc/controller-sdk-go"
18+
"github.com/stretchr/testify/assert"
1919
)
2020

2121
var (
@@ -90,7 +90,7 @@ func TestHealthZCircuitOpen(t *testing.T) {
9090
h := healthZHandler(bLister, c)
9191
w := httptest.NewRecorder()
9292
r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
93-
assert.NoErr(t, err)
93+
assert.Equal(t, err, nil)
9494
h.ServeHTTP(w, r)
9595
assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
9696
assert.Equal(t, w.Body.Len(), 0, "response body length")
@@ -105,7 +105,7 @@ func TestHealthZBucketListErr(t *testing.T) {
105105

106106
w := httptest.NewRecorder()
107107
r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
108-
assert.NoErr(t, err)
108+
assert.Equal(t, err, nil)
109109
h.ServeHTTP(w, r)
110110
assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
111111
assert.Equal(t, w.Body.Len(), 0, "response body length")
@@ -125,7 +125,7 @@ func TestReadinessNamespaceListErr(t *testing.T) {
125125
h := readinessHandler(client, nsLister)
126126
w := httptest.NewRecorder()
127127
r, err := http.NewRequest("GET", "/readiness", bytes.NewBuffer(nil))
128-
assert.NoErr(t, err)
128+
assert.Equal(t, err, nil)
129129
h.ServeHTTP(w, r)
130130
assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
131131
assert.Equal(t, w.Body.Len(), 0, "response body length")
@@ -145,7 +145,7 @@ func TestReadinessControllerErr(t *testing.T) {
145145
h := readinessHandler(client, nsLister)
146146
w := httptest.NewRecorder()
147147
r, err := http.NewRequest("GET", "/readiness", bytes.NewBuffer(nil))
148-
assert.NoErr(t, err)
148+
assert.Equal(t, err, nil)
149149
h.ServeHTTP(w, r)
150150
assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
151151
}
@@ -158,7 +158,7 @@ func TestHealthZSuccess(t *testing.T) {
158158
h := healthZHandler(bLister, c)
159159
w := httptest.NewRecorder()
160160
r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
161-
assert.NoErr(t, err)
161+
assert.Equal(t, err, nil)
162162
h.ServeHTTP(w, r)
163163
assert.Equal(t, w.Code, http.StatusOK, "response code")
164164
assert.Equal(t, w.Body.Len(), 0, "response body length")
@@ -178,7 +178,7 @@ func TestReadinessSuccess(t *testing.T) {
178178
h := readinessHandler(client, nsLister)
179179
w := httptest.NewRecorder()
180180
r, err := http.NewRequest("GET", "/readiness", bytes.NewBuffer(nil))
181-
assert.NoErr(t, err)
181+
assert.Equal(t, err, nil)
182182
h.ServeHTTP(w, r)
183183
assert.Equal(t, w.Code, http.StatusOK, "response code")
184184
assert.Equal(t, w.Body.Len(), 0, "response body length")

0 commit comments

Comments
 (0)